title: Cannot delete directory or files created with PHP (a.k.a permissions hell)
body: <p>Here's the scoop: I need to be able to create folders using a PHP script and also to upload image files to those folders. Here is my code:</p>
  
  <p><strong>Creating a directory:</strong></p>
  
  <pre><code>mkdir('[path]/images/foldername');  
  </code></pre>
  
  <p><br />
  <strong>Uploading Images:</strong></p>
  
  <pre><code>if ($_FILES["file"]["error"] &gt; 0 || $_FILES["file"]["type"] != "image/jpeg") // file must be valid and .jpg
  {
      echo "Error: " . $_FILES["file"]["error"] . "&lt;br /&gt;";
  }
  else
  {
      echo "Upload: " . $_FILES["file"]["name"] . "&lt;br /&gt;";
      echo "Type: " . $_FILES["file"]["type"] . "&lt;br /&gt;";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb&lt;br /&gt;";
      echo "Stored in: " . $_FILES["file"]["tmp_name"] . '&lt;br /&gt;';
  
      if(file_exists($path ."/" . $_FILES["file"]["name"]))
      {
          echo $_FILES["file"]["name"] . " already exists. ";
      }
      else
      {
          move_uploaded_file($_FILES["file"]["tmp_name"], $path ."/" . $_FILES["file"]["name"]);
          echo "Stored in: " . $path ."/" . $_FILES["file"]["name"];
      }
  }
  </code></pre>
  
  <p>FTP editor gives these errors:</p>
  
  <pre><code>[L] DELE 20.jpg
  [L] 550 Could not delete imagename.jpg: Permission denied
  </code></pre>
  
  <p>then</p>
  
  <pre><code>[L] RMD foldername
  [L] 550 Can't remove directory: Directory not empty
  </code></pre>
  
  <p>I tried changing the permissions in my FTP editor, but got this error:</p>
  
  <p>[L] SITE CHMOD 777 [path]/foldername
  [L] 550 Could not change perms on [path]/foldername: Operation not permitted
  <br />
  I tried using SSH with Putty to delete the file, but that did not work either.</p>
  
  <p>Please help me!</p>