Reputation: 349
I am using intervention image to save images to the public path in a laravel project. My code is as follows
Image::make($image)->resize(300, 300)->save( public_path($path . $filename ) );
I have ensured that the directory exists yet still receive an error
Intervention \ Image \ Exception \ NotWritableException
Can't write image data to path
I have found various ways to fix this in a linux environment with chown however I see none for windows. How can I fix this?
Upvotes: 1
Views: 2046
Reputation: 1353
put this before you save your image
if (!is_dir($path)) {
\File::makeDirectory($path, $mode = 0755, true, true);
}
but if you need best solution you need to use
\Storage::disk('public')->put(your_path,$image);
Upvotes: 1
Reputation: 661
that error doesn't mean you need permission , especially in windows environment
that means you send invalid path parameter (directory not existed)
lets say $path like this
$path = 'assets/uploads';
and then $filename like this
$filename = 'foo.bar';
last part for saving the image
Image::make($image)->resize(300, 300)->save( public_path($path . '/' . $filename ) );
Upvotes: 1