Hi all,
I am trying to download files from a remote with the use of ftp_get.
Somehow, the script always return to false.
Here's what I got:
[php]
$conn_id = ftp_connect($ft p_host);
$login_result = ftp_login($conn _id, $ftp_username, $ftp_password);
if ((!$conn_id) || (!$login_result )){
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_host for user $ftp_username";
exit;
} else {
echo "Connected to $ftp_host, for user $ftp_username";
//change directory
$ftp_chdir = ftp_chdir($conn _id,$remote_pat h);
//retrieves files in the directory
$file_slist = ftp_nlist($conn _id,$remote_pat h);
//open local directory
$dir_opn = opendir($local_ path);
//get all the remote files
foreach ($file_slist as $file_s) {
$ftp_get = ftp_get($conn_i d,$local_path.$ local_file,$rem ote_path.$file_ s,FTP_ASCII);
}
//close dir
closedir($ftp_c hdir);
//close ftp connection
ftp_close($conn _id);
} //else
[/php]
Do I set the right parameters?
Thanks in advice!
I am trying to download files from a remote with the use of ftp_get.
Somehow, the script always return to false.
Here's what I got:
[php]
$conn_id = ftp_connect($ft p_host);
$login_result = ftp_login($conn _id, $ftp_username, $ftp_password);
if ((!$conn_id) || (!$login_result )){
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_host for user $ftp_username";
exit;
} else {
echo "Connected to $ftp_host, for user $ftp_username";
//change directory
$ftp_chdir = ftp_chdir($conn _id,$remote_pat h);
//retrieves files in the directory
$file_slist = ftp_nlist($conn _id,$remote_pat h);
//open local directory
$dir_opn = opendir($local_ path);
//get all the remote files
foreach ($file_slist as $file_s) {
$ftp_get = ftp_get($conn_i d,$local_path.$ local_file,$rem ote_path.$file_ s,FTP_ASCII);
}
//close dir
closedir($ftp_c hdir);
//close ftp connection
ftp_close($conn _id);
} //else
[/php]
Do I set the right parameters?
Thanks in advice!
Comment