title: php rmdir or unlink file from folder
body: <p>The following code deletes the files in a folder <code>uploads</code>.How do I delete the folder as well when a user clicks <code>Delete Folder</code> (or similar).</p>
  
  <p>I tried using <code>rmdir</code> but I am not getting errors only blank move.php file.</p>
  
  <p>What's the correct/recommended way of doing it ? Please advice.</p>
  
  <pre><code>    &lt;?php
      $actfolder = $_REQUEST['folder'];
      require_once("models/config.php");
  
      if(!securePage($_SERVER['PHP_SELF'])){
          die();
      }
      require("models/db-settings.php");
  
      if(isset($_GET['file'])){
          $filename = "uploads/$loggedInUser-&gt;username$actfolder/" . ltrim($_GET['file'], '/\\');
          // make sure only deleting a file in files/ directory
          if (dirname(realpath($filename)) == realpath("uploads/$loggedInUser-&gt;username$actfolder/")) {
              unlink($filename);
          }
      }
      header("Location:".$_SERVER["HTTP_REFERER"]);
  ?&gt;
  </code></pre>