douhui0975 2011-12-01 04:21 采纳率: 100%
浏览 43
已采纳

强制破坏PHP FTP连接

I am downloading zip files from FTP server using PHP ftp function.I used binary and passive mode to get file. The problem is that when I stopped the ftp operation before the completion of ftp operation(ie ftp_close() was not called) and when it was started again it shows the following Warning-

  ftp_login() [http://php.net/function.ftp-login]: service unavailable
  FTP connection has failed!

And the FTP operation was failed.I have written the following code for FTP operation.

$connId = ftp_connect($host);   
$loginResult = ftp_login($connId, $user, $password);    
if ((!$connId) || (!$loginResult)) { 
    echo "FTP connection has failed!";
    exit; 
}   
ftp_pasv($connId, true);    
if (!ftp_chdir($connId, $remoteDir))
    return false;   
if (!ftp_get($connId, $localDir.$localFile,$remoteFile,FTP_BINARY))
    return false;   
ftp_close($connId);

How to forcefully destroy ftp connection which has started getting files in binary mode and the connection is in passive mode? Rebooting the machine or deleting the session cookies did not help me.What might be the possible solution for it?

  • 写回答

2条回答 默认 最新

  • douyu0845 2011-12-01 04:28
    关注

    Rebooting a machine always closes all connections made by or to that machine.

    ftp_login() [http://php.net/function.ftp-login]: service unavailable
    FTP connection has failed!

    It looks like the remote FTP server is terminating the connection before you ever get to the login step. Check that your credentials are correct and check to make sure the FTP server is operating correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?