0

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

Teoman Tıngır
  • 2,766
  • 2
  • 21
  • 41

1 Answers1

0

Is there featureds directory in storage?

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

Mosi
  • 198
  • 6