Forum Moderators: coopster

Message Too Old, No Replies

display images using php arrays

display images using php arrays

         

priddey

1:49 pm on Oct 14, 2007 (gmt 0)

10+ Year Member



Hi there,

This is a rookie question, sorry

I am trying to create a web page in which it has a gallery. I am using a array in php to read the image directory. I can display the file nakes from the directory out not the actual images. The code I am using is below, Can I do it this way?

$dir = 'Gallery';
$files = scandir($dir);
foreach($files as $image)
{
if (substr($image, 0, 1)!= '.')
{
$image_size = getimagesize ("$dir/$image");
$file_size = round ( (filesize("$dir/$image")) /1024). "kb";
?>

<ul id="albumlist">

<?php
echo "<li><img src='/gallery/$image'/>$image, $file_size</li>";

}
}
?>

dreamcatcher

6:41 pm on Oct 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

You have a capital G for the directory initially, but then in the code that shows the image is goes lowercase. Does that matter? What does your source code look like when you view it?

dc

priddey

7:04 pm on Oct 14, 2007 (gmt 0)

10+ Year Member



hello

I have changed the case the G, it doen't matter.
the code shown on IE is:

img src='/Gallery/Hut.JPG'/>Hut.JPG, 655kb
whicj ios correct, all the page is shpwing is a small square with a red cross and the file name and file sixe, so it is working as in so far that the file names is changinf but the picture doesnt show,