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?