title: How to delete 2 files with the same name from different folders?
body: <p>This is the php code:</p>
  
  <pre><code>if (array_key_exists('delete_file', $_POST)) {
    $filename = $_POST['delete_file'];
    if (file_exists($filename)) {
      unlink($filename);
      echo 'File '.$filename.' has been deleted';
    } else {
      echo 'Could not delete '.$filename.', file does not exist';
    }
  }
  </code></pre>
  
  <p>This is the form:</p>
  
  <pre><code>echo '&lt;form method="post"&gt;';
    echo '&lt;input type="hidden" value="'.$file.'" name="delete_file" /&gt;';
    echo '&lt;input type="submit" value="Delete image" /&gt;';
  echo '&lt;/form&gt;';
  </code></pre>
  
  <p>I have 2 folders, the images and the thumbnails. I would like to delete the file with the same name from the two folders. With the above code I can delete the file just frome one folder. Should I duplicate the first code and put a second hidden input in the form or what's the simpliest way to solve this problem? (<code>$file</code> contains the path and the file of the thumbnail, and <code>$file2</code> contains the path and the file of the big image)</p>