PHP下载图片函数
程序员文章站
2022-05-12 11:11:47
...
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抓取网站图片的程序