PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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:
<?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);
?>
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
Last edited by Benjamin on Mon Dec 27, 2010 1:52 pm, edited 1 time in total.
Reason:Added [syntax=php] tags.
It will save to the computer that's running the PHP code.
If you want it to save to your computer - the one that you're using right now - then you have to do a file download (with the Open/Save dialog and all that).