title: How to save uploaded file in a non-public folder using PHP
body: <p>I have code that successfully can upload a Word file onto my server. The problem is that it saves it in a subfolder of the location that the php file is in, so it is publicly available if someone puts the directory and filename. I want to save the file in a non-public folder but I can't figure out what the path is. I am on a shared server with cpanel on it.</p>
  
  <pre><code>$target_dir = "uploads/";
  $file_name = basename( $_FILES["fileToUpload"]["name"]);
  $target_file = $target_dir . $file_name;
  $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
  if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) 
  {
      echo "The file ". $file_name. " has been uploaded. &lt;br&gt;";
  } else {
      echo "Sorry, there was an error uploading your file.";
      exit;
  }
  move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)
  </code></pre>
  
  <p>The files are currently being saved to "/home/myusername/public_html/resume/uploads" but I want to save it to ""/home/myusername/uploads". I only know how to save the files to folders within the folder that the PHP program is in. I know this is probably really easy but I have been Googling this for a while and can't find the answer.</p>