PHP根据URL下载图片
时间:2021-07-01 10:21:17
帮助过:22人阅读
- 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://img.it-home.org/data/attachment/forum/2016pic2/logo.png";
- $rename = "koonk.png";
- imagefromURL($url,$rename);
- ?>
|
下载图片, PHP, URL