如何使用PHP将文件从托管服务器复制到本地驱动器


How to copy file from hosted server to local drive using PHP

我正在尝试在主机服务器和本地计算机之间传输文件。

我已经设法使它从我的本地计算机工作到我的托管服务器,但不能在其他方向。

我得到的错误是:

打开流失败:没有这样的文件或目录

下面是我的代码:
if(isset($_POST['btnSend'])) //submit button
{   
      if(count($_FILES['upload']['name']) > 0)
      //Loop through each file
        for($i=0; $i<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);
            }
       }
}

您需要从本地计算机使用FTP客户端访问服务器。服务器本身不能写入您的本地计算机,除非您将其本身转换为服务器。