[英]Can't write image data to path - Intervention Image
I'm trying to resize my images using Intervention package in my laravel project. 我正在尝试使用laravel项目中的Intervention包来调整图像大小。 I'm able to store images using Storage facade, but when I store them with Image class it throws below error.
我可以使用Storage Facade来存储图像,但是当我将其与Image类一起存储时,它会抛出以下错误。
Can't write image data to path (/var/www/commerce/storage/featureds/2-1537128615.jpg)
无法将图像数据写入路径(/var/www/commerce/storage/featureds/2-1537128615.jpg)
if ($request->has("featured_img")) {
$file_path = $request->get("featured_img");
$exp = explode("/",$file_path);
$filename = $exp[1];
$featured_path = "featureds/".$filename;
\Storage::copy($request->get("featured_img"), $featured_path);
\Image::make(\Storage::get($featured_path))->fit(400, 300)->save(storage_path($featured_path));
$product->media()->where("type", "featured")->update(["path" => $featured_path]);
}
How can I fix this ? 我怎样才能解决这个问题 ? Thanks for all your helps
谢谢你的帮助
Is there featureds directory in storage ? 存储器中是否有特色目录?
If no, you use mkdir to create directory because Intervention don't create directory automatically. 如果否,则使用mkdir来创建目录,因为Intervention不会自动创建目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.