21,886
社区成员
发帖
与我相关
我的任务
分享
public function GrabImage($url,$file) {//先读到缓冲区再下载,比直接下载好,直接下载可能下载不全
if($url=="") return false;
ob_start();//打开输出缓冲区,也就是暂时不允许输出
readfile($url);//读一个文件写入到输出缓冲
$img = ob_get_contents();
ob_end_clean();//下载完删除缓冲区,而不是输出
$size = strlen($img); // 图片大小
$fp2=fopen($file, "a");
fwrite($fp2,$img);
fclose($fp2);
return filesize($file);
}