Can't write image data to path - Intervention Image

三世轮回 提交于 2021-01-29 10:55:52

问题


I'm trying to resize my images using Intervention package in my laravel project. I'm able to store images using Storage facade, but when I store them with Image class it throws below error.

Can't write image data to path (/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


回答1:


Is there featureds directory in storage?

If no, you use mkdir to create directory because Intervention don't create directory automatically.



来源:https://stackoverflow.com/questions/52431142/cant-write-image-data-to-path-intervention-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!