tags:

views:

51

answers:

2

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);
        }
A: 

yes thats correct, but it would be be pretty easy to use glob in a foreach loop and get all files in a directory.

Galen
Oof... This is unclear to me... What's glob?
PoppySeedsAndAppleJuice
+1  A: 

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

Alec