ftp_get won't save locally
Posted: Mon Dec 27, 2010 10:39 am
Hi. Have I got this completely wrong? Is ftp_get meant to save to a local hard disc on a local computer?? Everything works ok ... but saves on the REMOTE Server not my LOCAL machine. The code reads:
As I said, date.php gets saved as tick.php perfectly ok ... on the remote server .. not my local computer. Any thoughts would be appreciated. Thanks
Code: Select all
<?php
// set up basic connection
$ftp_server = "mywebsite.co.uk";
$ftp_user_name = "someusername";
$ftp_user_pass = "somepassword;
// define some variables
$local_file = 'tick.php';
$server_file = '/date.php';
// 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);
ftp_pasv ($conn_id, true);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>