当前位置:Gxlcms > PHP教程 > PHP下载图片函数

PHP下载图片函数

时间:2021-07-01 10:21:17 帮助过:28人阅读

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

人气教程排行