您好我想要下载这样的gmail个人资料图片:
$src = 'https://lh3.googleusercontent.com/-MsxFngq63hA/AAAAAAAAAAI/AAAAAAAAAFc/kKIrjln2a_s/photo.jpg?sz=200';
有了这个卷曲:
$ch = curl_init ($src);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$rawdata=curl_exec($ch);
curl_close ($ch);
$fp=fopen("./imageProcess.jpg","w+");
fwrite($fp, $rawdata);
fclose($fp);
但结果图像为空白,大小为0。
有什么不对?
答案 0 :(得分:0)
不完全是你的代码,但是这个代码更短,而不是 curl complex
<?php
$content = file_get_contents($url);
file_put_contents("a.jpg", $current);
?>
希望这会有所帮助,除非您还想编辑原始标题