Please format your code by putting 3 backticks ``` on a line before and after each code block
Image Intervention... "Can't write image data to path ({$path})"
Hi, I am trying to resize my images I upload using Image Intervention but I am having the hardest time getting intervention to save. Laravel has no issue creating a folder and saving it, but then when I use Image it gives me the cant write image data to path error, even when I am using the same folder. I right clicked on the folder and gave permissions to everyone but that doesnt seem to help. Here is the code I am using in my controller.
//This all works $title = str_slug(request('title'));
$filenameWithExt = $request->file('cover_image')->getClientOriginalName();
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
$extension = $request->file('cover_image')->getClientOriginalExtension();
$fileNameToStore= $title.'.'.$extension;
$thumbnailpic= 'thumb'.'-'.$fileNameToStore;
//This store image creates the folder and saves the file
$path = $request->file('cover_image')->storeAs('public/cover_images', $fileNameToStore);
//Here is where I am trying to resize with image and it breaks
$file = Input::file('cover_image');
Image::make( $file->getRealPath() )->fit(340, 340)->save('public/cover_images/' . $thumbnailpic);
I have tried a ton of different methods for image, but none of them let image save to the folder. I am using the latest laravel 5.6 with valet for testing
easiest if you first breakdown the paths and check them and then use them in the Image library
So, assuming it is failing on the line you say
$source = storage_path().'/app/public/cover_images/'.$fileNameToStore;
$target = public_path('cover_images/' . $thumbnailpic);
dd($source, $target);
Image::make($source)->fit(340, 340)->save($target);
With the dd in there, you can check that these are both full filesystem paths to the source of the file and the target where it will be saved in its new size
Then you can just comment out the dd() and know what exactly what you are asking Intervention to do.
Please or to participate in this conversation.