Uploading files on the client is a common scenario that web development encounters. Don't repeat it here. Here we are going to elaborate on how to upload files to other servers on the service side.
This scenario is often encountered in a resource to synchronize multiple servers, such as a user uploading a picture from a server
Upload to another server.
In fact, uploading files on the server side is not a very difficult thing, as long as the PHP curl_init () can be done.
<?phprequire_once $_server [' document_root ']. ' /hosts.php ';//Ip$img_path of multiple servers = $_server [' document_root ']. ' /upload/test.jpg ';//image save path $file = Array ("Company_logo" = "@". $img _path);//file path, preceded by @, indicates file upload. foreach ($hosts as $host) {$curl = Curl_init ();//The URL that handles uploading a picture is the same as the principle that the client uploads the server curl_setopt ($curl, Curlopt_url, ' http://'. $host. ' /upload.php '), curl_setopt ($curl, curlopt_post,1), curl_setopt ($curl, Curlopt_postfields, $file); curl_setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, curlopt_header,0); curl_setopt ($curl, Curlopt_ssl_verifypeer, FALSE); $result = curl_exec ($curl); $result get page Information curl_close ($curl);}? >