Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - ftp all files in a directory?

Tags:

php

ftp

Trying to use php to get all files in a directory and save them locally... It seems like I constantly need to specify a name? Is that right?

function grabFiles() {
         $conn = ftp_connect(REMOTE);
             @ftp_login($conn, REMOTEUSER, REMOTEPASS);
             ftp_get($conn, '*', FTP_BINARY);
        }
like image 379
PoppySeedsAndAppleJuice Avatar asked Feb 28 '23 00:02

PoppySeedsAndAppleJuice


1 Answers

You can get a list of all the files using ftp_nlist:
http://www.php.net/manual/en/function.ftp-nlist.php

Go through that array and download each file using ftp_fget:
http://www.php.net/manual/en/function.ftp-fget.php

like image 98
Alec Avatar answered Mar 07 '23 07:03

Alec