dongshi3361 2011-11-29 06:54
浏览 79
已采纳

php通过FTP从服务器上传文件到另一个?

Hi I have a problem in transferring file from server to server I want to copy file like:

http://mysite1.com/myfile.jpg <-- I want this to copy or upload via ftp to mysite2.com

For example: http://mysite1.com/myfile.jpg upload to http://mysite2.com/fileuploads/

How to do this via PHP FTP transferring? Any hardcoder here can help my problem?

  • 写回答

1条回答 默认 最新

  • dongqu2863 2011-11-29 07:04
    关注

    Well here's one sample code, but you should read and try on your own before asking:

    $connection = ftp_connect($server);
    
    $login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
    
    if (!$connection || !$login) { die('Connection attempt failed!'); }
    
    $upload = ftp_put($connection, $dest, $source, $mode);
    
    if (!$upload) { echo 'FTP upload failed!'; }
    
    ftp_close($connection); 
    

    Hope it helps you getting started

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言Hurst指数
  • ¥15 Acrn IVSHMEM doorbell问题
  • ¥15 yolov5中的val测试集训练时数量变小问题
  • ¥15 MPLS/VPN实验中MPLS的配置问题
  • ¥15 materialstudio氢键计算问题
  • ¥15 echarts图表制作
  • ¥15 halcon根据玻璃面板纹路取区域
  • ¥15 HFSS设计小型化180度耦合器
  • ¥15 使用CInternetSession,CHttpFile读取网页文件时有些电脑上会卡住怎么办?
  • ¥15 水下机器人的半物理仿真研究