FTP get all files

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

But is there an easy way to load all of these files into the current directory?

I do not see to find examples of how I will do this.

thanks

+6
php ftp
source share
3 answers

Another simple solution is ...

List the files in the array and upload each file separately.

Something like:

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

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

You may need to change the code a bit ...

+5
source share

Yes there is. NanoFTPD is an old project since about 2003. It uses PHP to listen on the FTP port and process all requests from the client. It is able to perform all functions, including downloading (all) files to any directory you want. Take a look here

0
source share

Try using ftp_get ()

 $local_file = 'filename.txt'; $server_file = 'filename.txt'; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { echo "Successfully written to $local_file\n"; } else { echo "There was a problem\n"; } ftp_close($conn_id); 
0
source share

All Articles