title: Can I upload a file using PHP if I ONLY have the absolute path?
body: <p>What if I have no way of getting the input file:</p>
  
  <pre><code>&lt;input type="file" name="upload" id="upload"&gt;
  </code></pre>
  
  <p>After choosing the file I want to upload, the input field will disappear.
  Instead, it will display the absolute path:</p>
  
  <pre><code>C:\users\foo\Desktop\file.zip
  C:\fakepath\file.zip
  </code></pre>
  
  <p>Here's the code I used to get the absolute path:</p>
  
  <pre><code>&lt;script&gt;
  $('#upload').on('change',function(){
  
  var filename = document.getElementById("filename").innerHTML;
  
  $.ajax({
      type: "POST",
      url: "execs/upload.php",
      data: { filename: filename},
      dataType: "json",
      success: function (data) {
          alert ("Success")
      },
  
      error: function () {
          alert ("Failed")
      }
    });
  })
  &lt;/script&gt;
  </code></pre>
  
  <p>Will I still be able to upload it in PHP? Most of what I get online is that I will need $_FILES['filename']['tmp_name']. I don't know how I'll get it if I only have the absolute path.</p>
  
  <p>This is the upload.php file:</p>
  
  <pre><code>&lt;?php
  
  $filename = $_POST["filename"];  //C:\users\foo\Desktop\file.zip
  $target_dir = "uploads/";
  $target_file = $target_dir . $filename;
  
  if(move_uploaded_file($filename, $target_file)){  // $target_file = uploads/file.zip
  echo "yes";
  } 
  else echo "no";
  ?&gt;
  </code></pre>
  
  <p>When I also checked if the file exists ($filename), it says it does NOT.</p>
  
  <p>Any help would be very much appreciated! Thanks a lot!</p>