title: How to copy file from hosted server to local drive using PHP
body: <p>I am trying to transfer a file between my hosted server and my local computer.</p>
  
  <p>I have managed to make it work from my local computer to my hosted server, but not in the other direction.</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>Failed to open stream : No such file or directory</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>if(isset($_POST['btnSend'])) //submit button
  {   
        if(count($_FILES['upload']['name']) &gt; 0)
  
        //Loop through each file
          for($i=0; $i&lt;count($_FILES['upload']['name']); $i++) {
  
              //Get the temp file path
              $tmpFilePath = $_FILES['upload']['tmp_name'][$i];
              $fileType=$_FILES['upload']['type'][$i];
  
              //Make sure we have a filepath
              if($tmpFilePath != ""){
  
                  //save the filename
                  $shortname = $_FILES['upload']['name'][$i];
  
                  $fp      = fopen($tmpFilePath, 'r');
                  $content = fread($fp, filesize($tmpFilePath));
                  fclose($fp);
                  $content = addslashes($content);    
  
                  $path  = 'D:/Resumes_processed/'.$shortname;
  
                  copy($tmpFilePath, $path);
              }
         }
  }
  </code></pre>