rsquare
Newbie
- Jul 16, 2008
- 31
- 39
I use the following PHP script fragment to DL one file to my server and it works great. But I would like to DL multiple files from the same server. I would like to be able to call to a txt file with a list of the files and then download each in turn to the server. Any help, suggestions, or sample code would be appreciated.
Code:
$ftp_server = "server.com";
$ftp_user_name = "name";
$ftp_user_pass = "password";
$source_file = "/dir/file1.zip";
$destination_file = "/home/public_html/dl/file1.zip";
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed to $ftp_server as $ftp_user_name.<br />";
exit;
} else {
echo "Connected to $ftp_server successfully as $ftp_user_name.<br />";
}
$download = ftp_get($conn_id, $destination_file, $source_file, FTP_BINARY);
if (!$download) {
echo "FTP download has failed!";
} else {
echo "Downloaded $source_file from $ftp_server as $destination_file";
}
fclose($fp);