<?php

  $dir = './';
  if (file_exists($dir) && is_dir($dir) ) {
      $scan_arr = scandir($dir,1);
      $files_arr = array_diff($scan_arr, array('.','..','tree.php','index.php') );

      foreach ($files_arr as $file) {
        echo "<a href='$file'><img src='$file' width='50px'></a>"."&nbsp;";
      }
  }
  else {
    echo "Directory does not exist";
  }

?>