Listing all images in a directory using PHP
<p>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.</p>

<p>Errors:
Warning: rename(images/.,images/.) [function.rename]: No error in C:\wamp\www\Testing\listPhotosA.php on line 14</p>

<p>Warning: rename(images/..,images/..) [function.rename]: No error in C:\wamp\www\Testing\listPhotosA.php on line 14</p>

<p>Code:</p>

<pre><code>&lt;?php
define('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) &gt; 3){
    echo '&lt;img src="' . IMAGEPATH . $directoryfile . '" alt="' . $directoryfile . '" /&gt; &lt;br&gt;';
    }
}

closedir($handle);
</code></pre>

<p>?></p>
