【发布时间】:2016-01-07 07:49:21
【问题描述】:
当我在 laravel 4 中使用库干预/图像时,使用一段代码 $image = Image::make($url) 我遇到错误:
file_get_contents(http://ticket.at-newyork.com/image/tenboudai/rockfeller-top.jpg): failed to open stream: HTTP request failed! HTTP/1.1 410 Gone
我研究了很多关于 stackoverflow 的解决方案并尝试过:使用 urlencode 但我有另一个错误:
file_get_contents(http%3A%2F%2Fticket.at-newyork.com%2Fimage%2Ftenboudai%2Frockfeller-top.jpg): failed to open stream: No such file or directory
请不要建议我使用 curl,因为 file_get_contents() 是库中的代码,我无法更改。谢谢
【问题讨论】:
-
托管该图像的服务器是否阻止了盗链?
-
我不明白,我只知道 curl 可以解决问题但我不能使用,因为它是库中的代码,所以我无法更改
-
我刚刚尝试了 cURL 但它不起作用,它也返回 410 状态码。图像/站点的所有者阻止您像这样远程访问图像。谷歌“防止盗链”。
-
当我改变使用 cURL 时,它完全正确,我不知道为什么在你这边它返回 410 状态码,也许这不是原因
-
看at this question about cURL and images。查看@bbullis 关于用户代理检测的评论。如果我在 cURL 中设置用户代理,我会得到图像,如果没有,我会得到 410 状态。