php - Laravel 5.5 + 图像不可读错误(使用干预\图像)
问题描述
我使用 ImageOptimizer 包来减小图像大小。来源:http: //image.intervention.io/getting_started/installation
在控制器中:
if (Input::hasFile('title_image')) {
$Product = Input::file('title_image');
$filename = time() . '.' . $Product->getClientOriginalExtension();
Image::make($Product)->resize(300, 300)->save( public_path('/uploads/avatars/' . $filename) )->move(public_path() . '/../../products', md5($Product->getClientOriginalName()) . ".png");
$product->title_img = "products/" . md5($Product->getClientOriginalName()) . ".png";
}
我该如何解决这个错误???:
图像不可读
解决方案
getRealPath()
上传图片时使用。
if (Input::hasFile('title_image')) {
$Product = Input::file('title_image');
$filename = time() . '.' . $Product->getClientOriginalExtension();
Image::make($Product->getRealPath())->resize(300, 300)->save( public_path('/uploads/avatars/' . $filename) )->move(public_path() . '/../../products', md5($Product->getClientOriginalName()) . ".png");
$product->title_img = "products/" . md5($Product->getClientOriginalName()) . ".png";
}
推荐阅读
- javascript - jQuery - 更改多个表单列表中的按钮
- symfony - symfony 4 会话超时
- angular - Observable 类型上不存在属性捕获
- c# - Vlc.DotNet 设置音轨
- python-3.x - cx_Freeze 应用程序不会在命令提示符下打开并且不打印任何错误
- fonts - 为什么 Raleway 字体在我的网站上不起作用?
- javascript - 匹配两个不同的规则(javascript regexp)
- javascript - 如何获取数组中节点属性的值?
- xamarin - Xamarin.Controls.Signaturepad.Forms 返回黑色图像
- sharedpreferences - android sharedpreferences:nullPointerException