ftp_get won't save locally

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!

Moderator: General Moderators

Post Reply
tdmrider
Forum Newbie
Posts: 8
Joined: Mon Dec 27, 2010 10:29 am

ftp_get won't save locally

Post 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
Last edited by Benjamin on Mon Dec 27, 2010 1:52 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: ftp_get won't save locally

Post 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).
tdmrider
Forum Newbie
Posts: 8
Joined: Mon Dec 27, 2010 10:29 am

Re: ftp_get won't save locally

Post 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.
Post Reply