基础架构 thinkphp 5
实现效果:网络图片保存到本地(项目中制定路径)
代码片段
(png格式图片下载)
$qrcodeurl="http://localhost:8081/ymfile/20171218/20171218004234.png";
$imgFile = $qrcodeurl;
header('Content-type: image/png');
$QR = imagecreatefrompng($imgFile);
imagepng($QR, "qrimg/123.png");
imagedestroy($QR);
(jpg格式图片下载)
$qrcodeurl="http://localhost:8081/ymfile/20171218/20171218004220.jpg";
$imgFile = $qrcodeurl;
header('Content-type: image/jpeg');
$QR = imagecreatefromjpeg($imgFile);
imagejpeg($QR, "qrimg/abc.jpg");
imagedestroy($QR);