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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器