|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. edward_knoll@fpl.com |
|
#3
|
|||
|
|||
|
RE: REQEST : Upload a file to another remote server
can't ya just use the ftp functions?
|
|
#4
|
|||
|
|||
|
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.... |
|
#5
|
|||||
|
|||||
|
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: 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:
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. |
|
#6
|
|||
|
|||
|
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 |
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > REQEST : Upload a file to another remote server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|