Search code examples
laravelwindows-10file-permissionsintervention

Laravel Permissions on Windows For Saving in Public Path


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?


Solution

  • 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);