Uploading files on the client is a common scenario for Web development. I will not go into details here. Here we will elaborate on how to upload files to other servers on the server. This scenario is often used to synchronize resources on multiple servers. for example, you need to upload images uploaded by users from one server to another. In fact, uploading files on the server is not very difficult, as long as you use PHP curl_init. & Amp; lt... Upload files on the client, which is a common scenario for Web development. I will not go into details here. Here we will elaborate on how to upload files to other servers on the server.
This scenario is often used to synchronize resources on multiple servers. for example, you need to extract images uploaded by users from a server.
Upload to another server.
In fact, uploading files on the server is not very difficult, as long as you use PHP curl_init.
'@'. $ Img_path); // file path. add @ to the front to indicate that the file is uploaded. foreach ($ hosts as $ host) {$ curl = curl_init (); // process the URL of the uploaded image. The principle is the same as that of the client uploading to 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, expires, 1); curl_setopt ($ curl, CURLOPT_HEADER, 0); curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, FALSE); $ result = curl_exe C ($ curl); // $ result obtain the page information curl_close ($ curl);}?>