TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   How to copy file from server to server (http://www.talkphp.com/general/4914-how-copy-file-server-server.html)

benton 08-30-2009 01:12 AM

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 08-31-2009 01:41 AM

This is just a follow-up in case someone else runs into this. It turns out you have to perform a chdir on the remote server before this will work.


All times are GMT. The time now is 05:01 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0