Laravel 5.3使用URL中的图像进行干预/图像NotReadableException [英] Laravel 5.3 Intervention/image NotReadableException using images from urls

查看:646
本文介绍了Laravel 5.3使用URL中的图像进行干预/图像NotReadableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理以下错误,以便在发生异常时我的脚本不会停止工作:

How do I deal with the following error so that my script doesn't stop working when the exception occurs:

AbstractDecoder.php第302行中的NotReadableException:图像源不正确 可读

NotReadableException in AbstractDecoder.php line 302: Image source not readable

我尝试使用以下内容($ file是图像的url):

I've tried using the following ($file is the url of the image):

// Return false if error
try
{
    $img = Image::make($file);
}
catch(NotReadableException $e)
{
    return false;
}

这似乎没有捕获异常并返回false.我还能做什么?

This doesn't seem to catch the exception and return false. What else can I do?

推荐答案

您要么在catch区需要完整的命名空间异常,要么在文件顶部添加该异常的use语句

You either need the full namespaced exception in the catch area or add the use statement for that exception at the top of the file

这篇关于Laravel 5.3使用URL中的图像进行干预/图像NotReadableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆