|
Posted by FayeC on 11/26/05 00:52
I tried it and just modified the path as it is adding the username to
the path but I then get several errors
regarding not opening the stream and also a division by 0:
<?php
$username = $_POST['username'];
//$dir = $path."";
$path = "images/" . $username;
//print "$path<br>";
$i= strlen($path);
//print"$i<br>";
do{$i--;}
while(strpos($path,"/",$i)===false);
//print"$i<br>";
//print substr($path,0,$i);
$path=substr($path,0,$i+1);
$dir=$path;
// Open a known directory, and proceed to read its contents
//if (is_dir($dir)) {
$width=100;
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//print $dir . $file;
if($file!="." && $file!=".." &&
strtolower(substr($file,-3))=="jpg"){
$size = getimagesize($file);
$height=($size[1]*$width)/$size[0];
echo "<tr><td><img src='$file'width='$width'
height='$height'></td><td><b> <a
href=\"$file\">$file</a></b></td></tr>\n";
}
}
closedir($dh);
}
//}
?>
Gets:
Warning: getimagesize(joomla_logo_black.jpg) [function.getimagesize]:
failed to open stream: No such file or directory in
f:\apache_root\ucbaby\on\gallery.php on line 71
Warning: Division by zero in f:\apache_root\ucbaby\on\gallery.php on
line 73
FayeC
On Tue, 22 Nov 2005 07:04:13 +0000, Geoff Berrow
<blthecat@ckdog.co.uk> wrote:
>Message-ID: <i015o1d4ev501ijadrb4s5ptdg3d233j9m@4ax.com> from FayeC
>contained the following:
>
>>I need to create a code that will pull out 4 images from a folder that
>>will have the same username as the user's login.
>>After login the user is taken to a page that will contain the 4 images
>>in the folder arranged in a table or div.
>
>
>I started work on something similar last night.
>http://www.ckdog.co.uk/jladder/files.php
> It crudely shows .jpgs in a directory as thumbnails (simple browser
>resizing). I've still got quite a bit to do, but it may be useful.
>
>
><HTML>
><HEAD>
><TITLE>File management</TITLE>
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
></HEAD>
><BODY BGCOLOR="#FFFFFF" TEXT="#000000">
>
>
><table align="center" border="1" cellspacing="0" cellpadding="2">
><?php
>
>//$dir = $path."";
>$path=$_SERVER['PATH_TRANSLATED'];
>//print "$path<br>";
>$i= strlen($path);
>//print"$i<br>";
>do{$i--;}
>while(strpos($path,"/",$i)===false);
>//print"$i<br>";
>//print substr($path,0,$i);
>$path=substr($path,0,$i+1);
>$dir=$path;
>
>// Open a known directory, and proceed to read its contents
>//if (is_dir($dir)) {
>$width=100;
> if ($dh = opendir($dir)) {
> while (($file = readdir($dh)) !== false) {
> //print $dir . $file;
> if($file!="." && $file!=".." &&
>strtolower(substr($file,-3))=="jpg"){
>
> $size = getimagesize($file);
>
> $height=($size[1]*$width)/$size[0];
> echo "<tr><td><img src='$file'width='$width'
>height='$height'></td><td><b> <a
>href=\"$file\">$file</a></b></td></tr>\n";
> }
> }
> closedir($dh);
> }
>//}
>?>
>
>
></table>
></form>
></BODY>
></HTML>
Navigation:
[Reply to this message]
|