title: Specifying the correct directory for uploading files
body: <p>I have a folder called <code>uploads</code>, and files called, <code>upload.html</code> and <code>upload.php</code>. My <code>upload.html</code> looks like this (well, at least the relevant part does):</p>
  
  <pre><code>$(document).ready(function(){
      $("#pictureUploadSubmit").submit(function(event) {
          var file_data = $('#fileToUpload').prop('files')[0];   
          var form_data = new FormData();                  
          form_data.append('fileToUpload', file_data);
          alert(form_data);                             
          $.ajax({
              url: 'upload.php', // point to server-side PHP script 
              dataType: 'text',  // what to expect back from the PHP script, if anything
              cache: false,
              contentType: false,
              processData: false,
              data: form_data,                         
              type: 'post',
              success: function(php_script_response){
                  alert(php_script_response); // display response from the PHP script, if any
              }
          });
                      event.preventDefault(); 
      });
  });
  </code></pre>
  
  <p>And my <code>upload.php</code> looks like this:</p>
  
  <pre><code>&lt;?php
  $target_dir = "uploads/";
  $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  $uploadOk = 1;
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  // Check if image file is a actual image or fake image
  if(isset($_POST["submit"])) {
      $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
      if($check !== false) {
          echo "File is an image - " . $check["mime"] . ".";
          $uploadOk = 1;
      } else {
          echo "File is not an image.";
          $uploadOk = 0;
      }
  }
  // Check if file already exists
  if (file_exists($target_file)) {
      echo "Sorry, file already exists.";
      $uploadOk = 0;
  }
  // Check file size
  if ($_FILES["fileToUpload"]["size"] &gt; 500000) {
      echo "Sorry, your file is too large.";
      $uploadOk = 0;
  }
  // Allow certain file formats
  if($imageFileType != "jpg" &amp;&amp; $imageFileType != "png" &amp;&amp; $imageFileType != "jpeg"
  &amp;&amp; $imageFileType != "gif" ) {
      echo "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.";
      $uploadOk = 0;
  }
  // Check if $uploadOk is set to 0 by an error
  if ($uploadOk == 0) {
      echo "Sorry, your file was not uploaded.";
  // if everything is ok, try to upload file
  } else {
      if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
          echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
      } else {
          echo "Sorry, there was an error uploading your file.";
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Now, the file seems to be uploading but I think it is being uploaded into an incorrect directory because when I try to upload the same file twice, it echoes, <code>Sorry, file already exists</code> and when the image is successfully uploaded, it echoes <code>"The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."</code>. However, the files that are already in my FireFTP are not showing up in my <code>uploads</code> folder. </p>
  
  <p>I believe I have allowed for proper permission, namely, I allowed the read, write, and execute for my upload folder. </p>
  
  <p>So I think it is a misdirection of my <code>target directory</code>. I tried searching for the files that were uploaded and I think I checked all the directories, but I cannot find them. Anybody have a solution to this problem? </p>