Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsOtherTutorials

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 Codewalkers Forums Sponsor:
Old July 23rd, 2006, 04:24 AM
BuLB BuLB is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Philippines
Posts: 4 BuLB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to BuLB
REQEST : Upload a file to another remote server

i want to ask for some tutorials regarding uploading a file from my pc to another remote server


I have a php script that upload files from users computer to my webhost server.My question is how can i put the file of the users to be uploaded to other remote server that is not my web server.any one can help me? kindly put some tutorials or some program references that can help me

Reply With Quote
Old August 9th, 2006, 03:52 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: REQEST : Upload a file to another remote server

hey fella did you ever find a solution to this problem? I gots the same one.
Help appreciated.

email
edward_knoll@fpl.com

Reply With Quote
Old August 10th, 2006, 01:23 AM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,215 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Send a message via AIM to notepad
RE: REQEST : Upload a file to another remote server

can't ya just use the ftp functions?

Reply With Quote
Old September 5th, 2006, 08:00 PM
cybernine cybernine is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 73 cybernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
RE: REQEST : Upload a file to another remote server

if you wanted make a php script that uses ftp to upload from your computer to your web server and then moved via ftp to another server.

Finished....

Reply With Quote
Old November 4th, 2006, 03:24 AM
bluephoenix's Avatar
bluephoenix bluephoenix is offline
Levelheaded Curmudgeon
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Syracuse, NY
Posts: 508 bluephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 24 m 56 sec
Reputation Power: 8
Send a message via AIM to bluephoenix
RE: REQEST : Upload a file to another remote server

As a PHP developer, you may already be familiar with PHP's most handy file system function, fopen. The function opens a file stream and returns a resource which can then be passed to fread or fwrite to read or write data. Some people don't realize though that the file resource doesn't necessarily have to point to a location on the local machine.

Here's an example that transfers a file from the local server to an ftp server:

php Code:
Original - php Code
  1. $file = "filename.jpg";
  2. $dest = fopen("ftp://username:password@example.com/" . $file, "wb");
  3. $src = file_get_contents($file);
  4. fwrite($dest, $src, strlen($src));
  5. fclose($dest);


A listing of different protocols that are supported can be found in Appendix M of the PHP manual. You may wish to use a protocol that employs some encryption mechanism such as FTPS or SSH depending on the network setup and the sensitivity of the information you’re moving.

The curl extension makes use of the Client URL Library (libcurl) to transfer files. The logic of implementing a curl solution generally follows as such: first initialize a session, set the desired transfer options, perform the transfer and then close the session.

Initializing the curl session is done with the curl_init function. The function returns a resource you can use with the other curl functions much as how a resource is obtained with fopen in the file system functions.

The upload destination and other aspects of the transfer session are set using curl_setopt which takes the curl resource, a predefined constant representing the setting and the option’s value.

Here's an example that transfers a file from the local host to a remote server using the HTTP protocol's PUT method:

php Code:
Original - php Code
  1. $file = "testfile.txt";
  2.  
  3. $c = curl_init();
  4. curl_setopt($c, CURLOPT_URL, "http://example.com/putscript");
  5. curl_setopt($c, CURLOPT_USERPWD, "username:password");
  6. curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  7. curl_setopt($c, CURLOPT_PUT, true);
  8. curl_setopt($c, CURLOPT_INFILESIZE, filesize($file));
  9.  
  10. $fp = fopen($file, "r");
  11. curl_setopt($c, CURLOPT_INFILE, $fp);
  12.  
  13. curl_exec($c);
  14.  
  15. curl_close($c);
  16. fclose($fp);


A list of valid options for curl can be found in the php documentation.

The ftp extension allows you to implement client access to ftp servers. Using ftp to transfer a file is probably overkill when options like the previous two available... ideally this extension would be best used more advanced functionality is needed.

A connection is made to the ftp server using ftp_connect. You authenticate your session with the ftp server using ftp_login by supplying it a username and password. The file is placed on the remote server using the ftp_put function. It accepts the name of the destination file name, the local source file name, and a predefined constant to specify the transfer mode: FTP_ASCII for plain text transfer or FTP_BINARY for a binary transfer. Once the transfer is complete, ftp_close is used to release the resource and terminate the ftp session.

php Code:
Original - php Code
  1. $ftp = ftp_connect("ftp.example.com");
  2. ftp_login($ftp, "username", "password");
  3. ftp_put($ftp, "destfile.zip", "srcfile.zip", FTP_BINARY);
  4. ftp_close($ftp);


Reply With Quote
Old January 11th, 2007, 07:17 AM
girishpalmah girishpalmah is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mumbai, India
Posts: 3 girishpalmah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to girishpalmah
RE: RE: REQEST : Upload a file to another remote server


[quote]Hi
Code u displayed for upload a file using ftp is working fine. But using curl the content of the file in read mode goes to the ftp server not the file.Means content of file "example.txt" goes to ftp server where it is not saved as example.txt .So please reply soon.

Bye

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > REQEST : Upload a file to another remote server


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap