【发布时间】:2016-10-14 12:43:39
【问题描述】:
我尝试让一个 php 脚本将生成的图像输出为 .jpg 文件:
$url = 'http://www.photopost.com/photopost/showfull.php?photo=7541';
file_put_contents('image.jpg',file_get_contents($url));
$page = file_get_contents($url);
echo $page;
回显在浏览器中显示正确的图像。 但 image.jpg 没有保存。
我怎样才能做到这一点?
【问题讨论】:
-
我认为你需要设置标题。
header('Content-Type: image/jpeg');。关注这个php.net/manual/en/function.imagejpeg.php url -
ini 设置检查 echo ini_get('allow_url_fopen');
-
$url = "domain.com/showphoto.php?photo=10" 在 url 中找不到图片
-
ini_get('allow_url_fopen');显示:1