Sometimes, in order to achieve load or other reasons, we need to place the uploaded files on another server. because I am not familiar with the tools on the server, therefore, we only start with the php program and use the ftp or curl of php to upload files to the remote server.
Of course, both methods need to be uploaded to the current web server before being transferred to other servers.
The first method is to upload the file to the remote server through ftp, which requires the ftp IP address of the remote server. The ftp user and the Directory location permitted by the ftp password are required.
The ftp class provided by www.yawill.com is used. for details about how to use this class, see the attachment.
[Php]
Require "./ftp. class. php ";
$ A = ""; // Local path
$ B = ""; // remote file name
$ Ftp = new ClsFTP ("username", "password", '192. 202.202.202 '); // modify the settings
$ Ftp-> cd ('web'); // change to the directory. if you need to upload the file to the root directory, you do not need to change it.
$ Ftp-> put ($ B, $ a. "/". $ B); // put file
$ Ftp-> close ();
?>
[/Php]
2. Another method is to use curl to submit
This is not much different from normal php uploads in terms of processing uploads, but it is necessary to prevent malicious uploads by others. the source program is the work of other netizens. Unfortunately, the website cannot be opened.
[Php]
Echo"
";
Print_r ($ _ POST );
Print_r ($ _ FILES );
Echo"
";
// Upload process on the remote server
If (move_uploaded_file ($ _ FILES ['file1'] ['tmp _ name'] [1], './test.txt ')){
Echo 'OK ';
}
?>
[/Php]