Image: Can't write image data to the path

Created on 6 Jan 2018  路  6Comments  路  Source: Intervention/image

I got that error. I'm trying to resize an image for my photo gallery. folder should have the album_id, please help me to fix this.

Intervention \ Image \ Exception \ NotWritableException Can't write image data to path
Can't write image data to path (album_image/photos/16/1515270724.png)

Here's my code:

if($request->hasFile('photo')){
$photo = $request->file('photo');
$filenameToStore = time() . '.' . $photo->getClientOriginalExtension();
$location = $request->file('photo')->storeAs('album_image/photos/'.$request->input('album_id'), $filenameToStore);
Image::make($photo)->resize(500,500)->save($location);
}

Most helpful comment

I would double check the path you are trying to save to and ensure it exists.
This most often happens if the folder doesn't exist, so you'll need to check and ensure it exists in your code before saving.

If it does exist then perhaps check permissions on the folder, this depends on your operating system etc so best to Google that.

All 6 comments

Are you sure the directory exists? If so does it have the right permissions? That's usually the isue

an error
Can't write image data to path (/var/www/html/laravel_project/public/uploads/profileImage/1532779085.jpg)

Are you sure the directory exists? If so does it have the right permissions? That's usually the isue

I am also getting the same error. how do we have the right permission??

I would double check the path you are trying to save to and ensure it exists.
This most often happens if the folder doesn't exist, so you'll need to check and ensure it exists in your code before saving.

If it does exist then perhaps check permissions on the folder, this depends on your operating system etc so best to Google that.

@chris-faulkner you are perfectly right because it throws an error if the folder doesn't exist.

I think it's worth asking why the library doesn't auto-create the folder?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

REPTILEHAUS picture REPTILEHAUS  路  5Comments

cherrycoding picture cherrycoding  路  3Comments

p4bloch picture p4bloch  路  6Comments

kivivuori picture kivivuori  路  8Comments

anil-kumar-pal picture anil-kumar-pal  路  6Comments