Reputation: 1620
I have the following code
// Define the full path to your folder from root
$path = "../galleries/".$album;
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if(strlen($file)>1){echo "<a href='http://minification.com/?page_id=32&dir=$album&img=$file'><img src='http://minification.com/galleries/$album/$file'></a>";}
}
// Close
closedir($dir_handle);
What i want to do is pull in all the images from a folder and display them using PHP. So far its working up to the point where it only displays one image out of the folder. Anyone know how to fix this?
Upvotes: 1
Views: 1843
Reputation: 7291
Hint: If this is PHP 5, you can reduce the hassle a bit by using scandir
instead.
Upvotes: 3
Reputation: 40243
try this:
while(false !== ($file = readdir($handle))) {
A lot of different values evaluate to false in php so you may be getting a false positive.
Upvotes: 1
Reputation: 340506
Your second file probably evaulates to false, see readdir(), you should do:
while (false !== ($file = readdir($dir_handle))) {
Upvotes: 3