hugsbrugs / php-ftp

PHP FTP Utilities
7 stars 5 forks source link

download_dir and download_all issue #3

Open LunarDevelopment opened 5 years ago

LunarDevelopment commented 5 years ago

Hello!

Hopefully you can help - when I call download_dir it will download a few files then get stuck in a loop, eventually erroring out with something like the below: Warning: ftp_get(): Error opening ./Data/languages/plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plugins/../plu in /vendor/hugsbrugs/php-ftp/src/Hug/Ftp/Ftp.php on line 553

Note the line number 553 may be out slightly as I've added the passive mode line ftp_pasv($cid, true); near the top of the file. the line

if(ftp_get($cid, $local_dir . DIRECTORY_SEPARATOR . basename($file), $file, FTP_BINARY)) is line 553 for me.

http-tom commented 2 years ago

To fix this change line 524 of /src/Hug/Ftp/Ftp.php from $files = ftp_nlist($cid, $remote_dir); to $files = ftp_mlsd($cid, $remote_dir);

line 534 from if ($file != "." && $file != "..") to if ($file['type'] != "cdir" && $file['type'] != "pdir")

line 538 from if (Ftp::is_dir($file, $cid))// $remote_dir . DIRECTORY_SEPARATOR . to if ($file['type'] == 'dir')

Then whenever $file is used after this in that function (5 occurrences) change to $file['name']

Hope that helps someone.