Cannot save image intervention image. NotWritableException in Image.php line 138

You can solve it by casting the Intervation/Image variable to a data stream using function stream. Then use the Storage Laravel facade to save the image.

$img = Image::make('path-to-the-image.png')->crop(...)->insert->stream('jpg', 90)
Storage::put('where_I_want_the_image_to_be_stored.jpg', $img);

Ok so here is how i solved it, I made the directory first before storing,

Storage::disk('local')->makeDirectory('blogpost/' . $postId);

Once the folder is created i then go on to store the manipulated images like so:

$image->save(storage_path('app/blogpost/' . $postId . '/' . $imageName));

And then pushing the image to S3

$filesystem->put('blogpost/' . $postId . '/' . $imageName, file_get_contents(storage_path('app/blogpost/' . $postId . '/' . $imageName)));

This worked


Laravel 5 needs permission to write to entire Storage folder so try following,

sudo chmod 755 -R storage

if 755 dont work try 777.


Am improving @Amol Bansode answer.

You are getting this error because $postId folder does not exist in the path you specified.

You could do it like this:

//I suggest you store blog images in public folder
//I assume you have created this folder `public\blogpost`
$path = public_path("blogpost/{$postId}"); 

//Lets create path for post_id if it doesn't exist yet e.g `public\blogpost\23`
if(!File::exists($path)) File::makeDirectory($path, 775);

//Lets save the image
$image->save($path . '/' . $file->getClientOriginalName());