简体   繁体   中英

Can't write image data to path - Intervention Image

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

Is there featureds directory in storage ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM