PHP to save any network image to the server method,
This article explains how PHP saves any Web image to the server. Share to everyone for your reference. The specific analysis is as follows:
Arbitrarily specify a network image address, which is downloaded to the local server via this function
<?phpfunction SaveImage ($path) {if (!preg_match ('/\/(' ^\/]+\.[ a-z]{3,4}) $/i ', $path, $matches) die (' use image '); $image _name = Strtolower ($matches [1]); $ch = Curl_init ($path); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_binarytransfer,1); $img = curl_exec ($ch); Curl_close ($ch); $fp = fopen ($image _name, ' W '); Fwrite ($fp, $img); Fclose ($FP);} SaveImage (' http://www.bkjia.com/images/logo.jpg ');? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/984002.html www.bkjia.com true http://www.bkjia.com/PHPjc/984002.html techarticle PHP saves any network image to the server method, this article describes the PHP save any network image to the server method. Share to everyone for your reference. The specific analysis is as follows: Ren ...