Home  >  Article  >  Backend Development  >  PHP下载图片函数

PHP下载图片函数

WBOY
WBOYOriginal
2016-06-20 13:03:331173browse

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抓取网站图片的程序


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn