There is a need for the situation as follows:
Two servers, a test server [Apache], a production server [Nginx], product editors use PHP upload in the test servers to upload products in bulk, pictures, after checking,
Can synchronize its uploaded products and pictures [packaged into a zip file] on the production server, but the production server does not accept PHP upload upload files, then can not be on the test server directly post to the formal
Temporarily think of several methods:
1. Use rsync to manually sync past, but need to configure and require PHP to execute shell commands, but I don't want to.
2. You can use the socket to transfer the data, but you need to open the port, I do not want to do so, because if you forget at the firewall open port, it will not be able to transfer
3. Test server sends signal to production server, lets production server download files from test server using PHP Curl
by comparing, or the 3rd method is more appropriate, direct the entire process of using PHP to handle, at least reduce some unnecessary maintenance trouble.
The following is the method code content for php Curl download:
Function curl_download ($testing _server_file, $local _ File) {
$RFP = Curl_init ($testing _server_file);
$fp = fopen ($local _file, WB);
; curl_setopt ($CP, Curlopt_file, $fp);
curl_setopt ($CP, Curlopt_header, 0);
curl_exec ($RFP);
$errno = Curl_errno ($RFP);
$errmsg = Curl_error ($ RFP);
curl_close ($RFP);
fclose ($fp);
if ($errno) {
&nbs p; Echo $errmsg;
exit;
}
}