Below are the functions that I use to download a FTP folder, recursively. I ran this several times, but after a successful run for like 1-2 mins, it always stops on the same spot, at the same file, generating this :
...... ...... Downloaded: login-bkg-bottom.gif Downloaded: login-bkg-tile.gif Downloaded: logo-ghost.png Downloaded: logo-login.gif Downloaded: logo.gif Downloaded: marker.png Downloaded: mask.png
Warning: ftp_pwd() [function.ftp-pwd]: 0.125 seconds (measured here), 15.74 Kbytes per second in C:\xampp\htdocs\something\asdasd\recursive_download.php on line 16 Reconnecting ...
Warning: ftp_get() [function.ftp-get]: 0.125 seconds (measured here), 15.74 Kbytes per second in C:\xampp\htdocs\something\asdasd\recursive_download.php on line 90 --> Didn`t Download: media-button-image.gif
Warning: ftp_get() [function.ftp-get]: 0.125 seconds (measured here), 15.74 Kbytes per second in C:\xampp\htdocs\something\asdasd\recursive_download.php on line 90 --> Didn`t Download: media-button-music.gif
Warning: ftp_get() [function.ftp-get]: 0.125 seconds (measured here), 15.74 Kbytes per second in C:\xampp\htdocs\something\asdasd\recursive_download.php on line 90 --> Didn`t Download: media-button-other.gif
and a few more messages like this, and that's that. I checked permissions to the file, since I suspected a different user/group but I'm able to get the files correctly with any FTP client, plus the owner/group/permissions are the same for all files ...
Any ideas are appreciated. I'm downloading on a Windows PC, if that helps.
function ftp_download_all ($conn_id,$dir) {
ftp_getonline();
logdata('Location: '.ftp_pwd($conn_id));
if ($dir != ".") {
if (ftp_chdir($conn_id, $dir) == false) {
echo ("Change Dir Failed: $dir<BR>\r\n");
return;
}
if (!(is_dir($dir)))
mkdir($dir);
logdata('Create: '.$dir);
chdir ($dir);
}
$contents = ftp_nlist($conn_id, ".");
foreach ($contents as $file) {
if ($file == '.' || $file == '..')
continue;
ftp_getonline();
if (@ftp_chdir($conn_id, $file)) {
ftp_chdir($conn_id, "..");
logdata('Enter: '.$dir);
ftp_getonline();
ftp_download_all ($conn_id,$file);
}
else
{
ftp_getonline();
if (!ftp_get($conn_id, $file, $file, FTP_BINARY))
logdata('--> Didn`t Download: '.$file);
else
logdata('Downloaded: '.$file);
}
}
ftp_getonline();
ftp_chdir ($conn_id, "..");
chdir ("..");
}
function ftp_getonline()
{
global $host,$port,$user,$pass,$ftppath,$localpath,$cur_dwl_path,$conn_id;
$cnt = 0;
if(!ftp_pwd($conn_id))
{
logdata('Reconnecting ...');
do{
if($conn_id = ftp_connect($host,$port,15))
{
if(ftp_login($conn_id,$user,$pass))
{
ftp_pasv( $conn_id, true );
}
else
logdata('! Could not log in !');
}
else
{
logdata('! Could not connect !');
$cnt++;
sleep(3);
}
}while(!$conn_id && ($cnt < 10));
}
}