giba Posted January 7, 2009 Share Posted January 7, 2009 Hi there guys! I am trying to get all files of a remote folder via FTP, but I got no sucess until now! How could I do this? Link to comment https://forums.phpfreaks.com/topic/139881-how-to-list-or-get-all-files-of-a-remote-folder-via-ftp/ Share on other sites More sharing options...
giba Posted January 7, 2009 Author Share Posted January 7, 2009 I solved it by myself, so I will post here for who would like to save time when such a problems happen: 1) create a file on the server listing all files in such a directory: [pictures.php] <?php $p = null; foreach (glob("pictures/*.jpg") as $file) { $p .= $file.','; } $p .= 'end'; echo $p; ?> 2) get the content of this file from such a file: [get-list.php] $file= file_get_contents('http://www.server.com/path/to/file/pictures.php'); $file = str_replace(',end','',$file); $f = explode(",",$file); foreach ($f as $file) { /* * Any code here for get the files, * I used a class you can do it your way */ $files->get($server, $local); } That's it, I solved it so! Link to comment https://forums.phpfreaks.com/topic/139881-how-to-list-or-get-all-files-of-a-remote-folder-via-ftp/#findComment-731943 Share on other sites More sharing options...
jonsjava Posted January 7, 2009 Share Posted January 7, 2009 Hi there guys! I am trying to get all files of a remote folder via FTP, but I got no sucess until now! How could I do this? here's a basic login=>get list=>print array of files/folders <?php // set up basic connection $ftp_server = "example.com"; $ftp_user_name = "example_user"; $ftp_user_pass = "password"; $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // get the file list for / $buff = ftp_nlist($conn_id, '/'); // close the connection ftp_close($conn_id); // output the buffer print_r($buff); ?> just realized you wanted the files, not just a list of files. Link to comment https://forums.phpfreaks.com/topic/139881-how-to-list-or-get-all-files-of-a-remote-folder-via-ftp/#findComment-731947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.