使用PHP将映像从一个远程服务器复制到另一个远程服务器

时间:2017-07-05 07:05:17

标签: php

public function foo_bar_testing()
{
         $upload_path = "uploads/";
         $newname = "image.jpg";
         $name= $_FILES['file']['name'];
         $type= $_FILES['file']['type'];
         $size= $_FILES['file']['size'];
         $tmp_name=$_FILES['file']['tmp_name'];     
         $error=$_FILES['file']['error'];

        move_uploaded_file($_FILES['file']['tmp_name'],'./'.$upload_path.$newname);
        $newname=$newname.".".$ext;

            /////////////////////
            $conn_id = ftp_connect('ftp.server.com');           
        $login_result = ftp_login($conn_id, 'xyz@server.com', '****');

        $file = "http://**.**.**.**/folder/".$upload_path.$newname;
        $remote_file = "http://***.**.**.**/XYZ/".$upload_path.$newname;
        if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
         echo "successfully uploaded $file\n";
        } else {
         echo "There was a problem while uploading $file\n";
        }
        ftp_close($conn_id);
    }

嗨,我正在尝试将上传到服务器的图像复制到另一台远程服务器。以上是我的代码,但我很困惑如何做到这一点。我想创建一个备份上传到当前远程服务器的映像,然后将它们复制到另一个远程服务器。

先谢谢

0 个答案:

没有答案