Page 1 of 1

ftp_get won't save locally

Posted: Mon Dec 27, 2010 10:39 am
by tdmrider
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:

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);
?>
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

Re: ftp_get won't save locally

Posted: Mon Dec 27, 2010 12:16 pm
by requinix
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).

Re: ftp_get won't save locally

Posted: Mon Dec 27, 2010 1:14 pm
by tdmrider
Thanks Tasairis ... more or less what I thought the answer might be!! Nuffins ever easy is it. Oh well, back to the drawing board.