title: How to display images to delete using PHP Unlink
body: <p>I have a script that deletes images from a folder using PHP.</p>
  
  <p>The problem is the images arenot being displayed on the page.</p>
  
  <p>My code is as below</p>
  
  <pre><code>&lt;?php
  // directory separator
  defined("DS")
      || define("DS", DIRECTORY_SEPARATOR);
  
  // root path
  defined("ROOT_PATH")
      || define("ROOT_PATH", realpath(dirname(__FILE__)));
  
  // upload folder directory
  defined("UPLOAD_DIR")
      || define("UPLOAD_DIR", "uploads");
  
  // path to the upload folder
  defined("UPLOAD_PATH")
      || define("UPLOAD_PATH", ROOT_PATH.DS.UPLOAD_DIR);
  
  
  function getAllFiles($folder = null) {
      if(!empty($folder) &amp;&amp; is_dir($folder)) {
          if($handle = opendir($folder)) {
              $out = array();
              while($file = readdir($handle)) {
                  if(is_file($folder.DS.$file)) {
                      $out[] = $file;
                  }
              }
              closedir($handle);
              return $out;
          }
          return false;
      }
      return false;
  }
  
  $files = getAllFiles(UPLOAD_PATH);
  
  if (!empty($_POST['file'])) {
      foreach($_POST['file'] as $file) {
          unlink(UPLOAD_PATH.DS.$file) or die("Failed to &lt;strong class='highlight'&gt;delete&lt;/strong&gt; file");
      }
      header("location: " . $_SERVER['REQUEST_URI']);
  }
  ?&gt;
  
  &lt;?php if (!empty($files)) { ?&gt;
  
  &lt;form name="form1" method="post"&gt;
      &lt;?php foreach($files as $key =&gt; $file) { ?&gt;
          &lt;label for="file_&lt;?php echo $key; ?&gt;"&gt;
              &lt;input type="checkbox" name="file[]" id="file_&lt;?php echo $key; ?&gt;" value="&lt;?php echo $file; ?&gt;" /&gt; 
              &lt;?php echo $file; ?&gt;
          &lt;/label&gt;
      &lt;?php } ?&gt;
      &lt;input type="submit" name="delete" value="Delete" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code works fine to delete the images but does not display the images on the page.</p>
  
  <p>Your help is much apprecited.</p>
  
  <p>Thank You </p>