The example in this article describes how the PHP implementation asynchronously writes the content (picture or content) on a remote link to the local method. Share to everyone for your reference, specific as follows:
/** * Writes the content (picture or content) on the remote link asynchronously to the local * @param unknown $URL * Remote address * @param unknown $s Avename * file name saved on the server * @param unknown $path * Save path * @return Boolean/function Put_file_from_url_content ($url, $saveName = ' tmp.png ', $path = './uploads/tmp/')
{//Set run time to unrestricted set_time_limit (0);
$url = Trim ($url);
$curl = Curl_init ();
Set the URL you need to crawl curl_setopt ($curl, Curlopt_url, $url);
Set HEADER curl_setopt ($curl, Curlopt_header, 0);
Sets the curl parameter to require that the results be saved to the string or to the screen.
curl_setopt ($curl, Curlopt_returntransfer, 1);
Run Curl, request Web page $file = curl_exec ($curl);
Closes the URL request curl_close ($curl); Writes a file to the obtained data $filename = $path.
$saveName;
$write = @fopen ($filename, "w");
if ($write = = False) {return false;
} if (Fwrite ($write, $file) = = False) {return false;
} if (fclose ($write) = = False) {return false;
return $filename; }
More about PHP Interested readers can view the site topics: "Php Curl Usage Summary", "PHP Array" operation Skills Encyclopedia, "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Mathematical Calculation Skills Summary", " PHP Regular Expression Usage summary, "Summary of PHP operations and operator usage", "PHP string (String) Usage summary" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.