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 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口