【发布时间】:2018-05-09 16:52:58
【问题描述】:
我像这样运行命令
wget https://odis.homeaway.com/odis/listing/5895882c-6c65-47f5-b782-e13b8246e4aa.c10.jpg
我尝试使用 curl 获取上面的图像,返回的图像是无效的 jpg 图像。当我尝试使用浏览器并将图像另存为时,我得到有效的 jpg 图像。即使我尝试使用 file_get_contents 它也会返回 false。
$image = 'https://odis.homeaway.com/odis/listing/5895882c-6c65-47f5-b782-e13b8246e4aa.c10.jpg'
$image_data = file_get_contents($image);
try {
echo 'saving';
$image1 = imagecreatefromjpeg($image_data);
} catch (Exception $ex) {
echo 'error';
}
如何使用curl、wget 或file_get_contents 获取此图像?
【问题讨论】:
-
不,我在 curl 的情况下尝试相同的代码,但我得到无效的 jpg 图像说不是 JPEG 文件:以 0x89 开头,我尝试保存在 png/gif 中,仍然不起作用
-
我已经尝试了所有选项 1. wget 2. curl 3. file_get_contents,在每种情况下我都会得到无效的图像