Heim >Backend-Entwicklung >PHP-Tutorial >PHP下载图片函数
function imagefromURL($image,$rename)<br />{<br />$ch = curl_init($image);<br />curl_setopt($ch, CURLOPT_HEADER, 0);<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);<br />$rawdata=curl_exec ($ch);<br />curl_close ($ch);<br />$fp = fopen("$rename",'w');<br />fwrite($fp, $rawdata); <br />fclose($fp);<br /><p>}</p><p>
语法:
<p><?php</p><p>$url = "http://www.scutephp.com/images/logo.png";</p><p>$rename = "logo.png";</p><p>imagefromURL($url,$rename);</p><p>?></p><p>
其他PHP图片下载函数
php抓取网站图片的程序