View Single Post
Old 08-30-2009, 01:12 AM   #1 (permalink)
benton
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default How to copy file from server to server

I am trying to write a script that will cycle through a list of other servers and copy files from those remote servers to the one the script is on. I've tried the script below but it fails, stating the remote file doesn't exist, even though it does. I've never tried these functions before so I don't know if I am using them incorrectly or doing something else wrong. Does anyone see a problem with the code or have a suggestion as to a better way to do this?

PHP Code:
$server 'my_domain)name.com';
$ftp_user_name 'username';
$ftp_user_pass 'password';

$local '/home/username_server_local/testto.php';
$remote '/home/username_server_remote/test_files/test.php';

$connection ftp_connect($server);
$login ftp_login($connection$ftp_user_name$ftp_user_pass);
if (!
$connection || !$login) { die('Connection attempt failed!'); }

ftp_pasv $connectiontrue ) ;
$upload ftp_get($connection$local$remoteFTP_ASCII);

if (!
$upload) { echo 'FTP upload failed!'; }

ftp_close($connection); 
benton is offline  
Reply With Quote