TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-30-2009, 01:12 AM   #1 (permalink)
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
Old 08-31-2009, 01:41 AM   #2 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

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.
benton is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is my file? superthin General 3 07-25-2009 09:48 AM
mail problem galleeandfarel Absolute Beginners 10 02-10-2009 12:17 PM
Aptana Jaxer and file uploads xenon Advanced PHP Programming 2 06-06-2008 10:22 AM
Writing to XML file buildakicker General 8 02-06-2008 08:17 PM
Using curl to read a file from an external server? bdm Advanced PHP Programming 10 12-04-2007 12:46 AM


All times are GMT. The time now is 10:21 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design