Hi
I'm trying to run a simple FTP script that gets a file from an FTP server and places it locally. The script is
When I run it, I get the error:
Warning: ftp_get(): 1 is not a valid FTP Buffer resource in ****************** on line 21
Then an empty file is transferred to the local destination. Please can someone tell me where I'm going wrong??
Thanks
Chris
I'm trying to run a simple FTP script that gets a file from an FTP server and places it locally. The script is
Code:
<?php
// set up basic connection and login with username and password
$ftp_server="********";
$ftp_user_name="****";
$ftp_user_pass="****";
$day=str_pad(date("z")+1,3,"0",STR_PAD_LEFT);
$source_file='*******************';
$destination_file='******************';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
ftp_close($conn_id);
if (ftp_get($conn_id, $destination_file, $source_file, FTP_ASCII)) {
echo "FTP upload has failed!";
} else {
echo "Downloaded $source_file From $ftp_server to $destination_file";
}
?>
When I run it, I get the error:
Warning: ftp_get(): 1 is not a valid FTP Buffer resource in ****************** on line 21
Then an empty file is transferred to the local destination. Please can someone tell me where I'm going wrong??
Thanks
Chris