Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP get all files

Tags:

php

ftp

I have successfully connected to my FTP using PHP and I can see all the files using: ftp_nlist

But, is there an easy way to then download all these files in the current directory?

I can't see to find any examples of how I'd do this.

Thanks

like image 427
terrid25 Avatar asked Mar 16 '11 16:03

terrid25


1 Answers

Another simple solution is ....

List the files in an array and download each file individually.

Something like:

$contents = ftp_nlist($conn_id, ".");

foreach ($contents as &$value) { $result = ftp_fget($conn_id, $local,&$value, FTP_BINARY); }

You might need to tweak the code a little...

like image 187
slotishtype Avatar answered Nov 03 '22 03:11

slotishtype