Sometimes in order to achieve load or other reasons, we need to place the uploaded files on other servers. Since I am not familiar with the tools on the server, I only start with the PHP program and use PHP's ftp or curl. To upload files to a remote server
Of course, both methods need to upload to the current web server first, and then transfer to other servers
The first method is to upload to the remote server via ftp, which requires a remote The server's ftp IP address, ftp user and ftp password are in the directory location allowed by permissions
The ftp class provided by www.yawill.com is used. Please see the attachment for the specific usage of this class
[php]
<?php require "./ftp.class.php"; $a = "";//本地路径 $b = "";//远程文件文件名 $ftp = new ClsFTP("username","password",'202.202.202.202');//自行修改设置 $ftp->cd('web');//更改到目录,如果你需要上传到根目录就不用改了 $ftp->put($b,$a."/".$b);//put file $ftp->close(); ?> [/php]
ftp upload source file And demo download
http://www.dayanmei.com/download.php?filename=ftpclass.rar
2. Another method is to use curl to submit
This is not much different from ordinary PHP upload in terms of upload processing , but we need to prevent others from uploading maliciously. The source program is the work of other netizens. Unfortunately, the URL can no longer be opened
[php]
<?php echo "<pre class="brush:php;toolbar:false">"; print_r($_POST); print_r($_FILES); echo "";
//Here is the upload processing of the remote server
if(move_uploaded_file($_FILES[ 'file1']['tmp_name'][1],'./test.txt')){
echo 'ok';
}
?>
[/php]
curl upload source file and demo download
http ://www.dayanmei.com/download.php?filename=curl_upload.rar