Listing all images in a directory using PHP

plAyboy

New Member
I have the code below that lists all the images in a folder, the problem is that it finds some files ( a . and a ..) that I am not sure what they are so I am not sure how to prevent them from showing up. I am on a windows XP machine, any help would be great, thanks.Errors:Warning: rename(images/.,images/.) [function.rename]: No error in C:\wamp\www\Testing\listPhotosA.php on line 14Warning: rename(images/..,images/..) [function.rename]: No error in C:\wamp\www\Testing\listPhotosA.php on line 14Code:\[code\]<?phpdefine('IMAGEPATH', 'images/');if (is_dir(IMAGEPATH)){ $handle = opendir(IMAGEPATH);}else{ echo 'No image directory';}$directoryfiles = array();while (($file = readdir($handle)) !== false) { $newfile = str_replace(' ', '_', $file); rename(IMAGEPATH . $file, IMAGEPATH . $newfile); $directoryfiles[] = $newfile;}foreach($directoryfiles as $directoryfile){ if(strlen($directoryfile) > 3){ echo '<img src="' . IMAGEPATH . $directoryfile . '" alt="' . $directoryfile . '" /> <br>'; }}closedir($handle);\[/code\]?>
 
Back
Top