PHP下载图片函数
程序员文章站
2022-04-23 21:43:26
...
function imagefromURL($image,$rename)
{
$ch = curl_init($image);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
$fp = fopen("$rename",'w');
fwrite($fp, $rawdata);
fclose($fp);}
语法:
$url = "http://www.scutephp.com/images/logo.png";
$rename = "logo.png";
imagefromURL($url,$rename);
?>
其他PHP图片下载函数
php抓取网站图片的程序