title: Listing all images in a directory using PHP
body: <p>I have the code below that lists all the images in a folder, the problem is that it finds some files <strong>( a . and a ..)</strong> that I am not sure what they are so I am not sure how to prevent them from showing up. I am on a <strong>windows XP machine</strong>, any help would be great, thanks.</p>
  
  <blockquote>
    <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>
  </blockquote>
  
  <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); ?&gt;
  </code></pre>