FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 17th, 2002, 11:10 AM
martincrumlish martincrumlish is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Ireland
Posts: 169 martincrumlish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 42 m 53 sec
Reputation Power: 7
uploading a file to more than one server: useing PHP's FTP function

Hi,

I want to make a quick little app to save time for something I have to do in work. I frequently have to upload a latest.gif to 4 different web servers using FTP programs. This is quite annoying so I decided I am going to try to make a PHP script that will upload the file to all 4 web servers at once from one form field and 1 submit button.

Does anyone know how I would do this?

The servers are all duplicated of each other and have the same password and username as well as paths etc.

It would be very handy if I could put this together and would be one less monotonous task for me to do every day.

Thanks in advance,
Martin

PS: This doesnt need to be too advanced, it just needs to upload the image to the 4 servers and to confirm that the upload worked.

Reply With Quote
  #2  
Old December 17th, 2002, 11:36 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Just make a loop that goes through each address to upload to and repeat the ftp upload to each one.
Something like this: (this is untested, written on the fly)
PHP Code:
 $addr = array('ftp_address1','ftp_address2');
$ftp_user 'your_user_id';
$ftp_pass 'your_pass';
$path_to_upload '/some/path';
$filename '/path/to/your_file_to_upload.txt';
foreach(
$addr as $ftp_adr) {
    
$con=ftp_connect($ftp_art) or die('Unable to connect to ftp location.');
    
ftp_login($con,$ftp_user,$ftp_pass) or die('Failed to logon as '.$ftp_user);
    
ftp_chdir($con,$path_to_upload);
    
ftp_put($con,$filename,$filename,FTP_BINARY) or die('Failed to upload file.');
    
ftp_close($con);


Reply With Quote
  #3  
Old December 17th, 2002, 11:40 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 72717 Folding Title: Intermediate FolderFolding Points: 72717 Folding Title: Intermediate FolderFolding Points: 72717 Folding Title: Intermediate FolderFolding Points: 72717 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 20 h 19 m 49 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
What do you have so far? There are examples in the manual and it's about the same as fopen(), fwrite(), etc...

PHP Code:
 $server = array('ip1','ip2','ip3','ip4');
foreach(
$server as $ip)
{
  
$cid ftp_connect($ip);
  
ftp_login($cid,$user,$password);
  
ftp_put($cid$dest$sourceFTP_BINARY);
  
ftp_close($cid);


---John Holmes...

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > uploading a file to more than one server: useing PHP's FTP function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT