Ftp local file to remote server
Posted: Mon Aug 04, 2014 5:57 am
Hi all, very new at this so sorry in advance.
I have a php script that runs every 4 hours on a cron job that creates a binary file that contains property info called atp100.blm
so the php script and the blm file are in the same location in the root of the website. I am then trying to ftp this blm file to a remote server but I cant seem to get this to work at all. The idea is to run a separate php script every 12 hours to upload this file to a company.
I keep getting this message "There was a problem while uploading atp100.blm"
Thanks in advance
Steve
I have a php script that runs every 4 hours on a cron job that creates a binary file that contains property info called atp100.blm
so the php script and the blm file are in the same location in the root of the website. I am then trying to ftp this blm file to a remote server but I cant seem to get this to work at all. The idea is to run a separate php script every 12 hours to upload this file to a company.
I keep getting this message "There was a problem while uploading atp100.blm"
Thanks in advance
Steve
Code: Select all
<?php
$ftp_server="IP";
$ftp_user_name="USER";
$ftp_user_pass="PASS";
$file = "atp100.blm";
$remote_file = "/htdocs/atp100.blm";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
exit;
} else {
echo "There was a problem while uploading $file\n";
exit;
}
// close the connection
ftp_close($conn_id);
?>