Can't write image data to path - Intervention Image

Posted on: 22/05/2018. Last updated at: 05/06/2020

I'd been wracking my brain for a few days about this, searching the web for a solution to "Can't write image data to path (storage/thumbs/filename.jpeg)". Then it finally hit me, it was a permissions issue.

I needed to give the webserver (Apache in my case) ownership of the folder i was wanting to save files to. My current setup is to share the ownership of the files / folders with myself and the webserver.

You can see my post about how to set file permissions for Laravel 5 on mac OSX, for more details.

As you can see from the screenshot below, within my storage/app/public folder i have a thumbnails folder which i wanted to save images to.

File permissions of the laravel storage folder

My user and _www share ownership of the folder. All i needed to do was change the ownership to be Apache for both. To do this type the following command in your terminal window:

cd yourprojectname/storage/app/public
sudo chown _www:_www thumbnails

The only side effect of this is that if you ever need to delete the files from the folder, you'll have to type your password in to authorise it, since you are no longer the owner of the files. However in a production environment it will be very likely that the webserver is the owner of all the files and folders in your project, so you'll never come across this problem, only when developing locally.

As a side note, You can use this fix for any project you use Intervention Image with. It's not Laravel dependant.

Hope this helps someone!


Picture of Daniel Ord
Daniel Ord

Building things for the Web. Follow me on Twitter or checkout my GitHub.

More Posts

How to use Laravel Forge with Amazon Web Services EC2
Laravel Forge is a great tool to help you provision your own servers, however if you want to use AWS...
Google Authenticator not working? Your server could be out of sync
I recently came across a strange issue where the Google Authenticator we use suddenly stopped working. It worked fine on...
Upload multiple files, create thumbnails with Spatie MediaLibrary
Not sure how to use Spatie Media-Library? This guide shows you how to upload multiple images with thumbnail conversion and...
How to setup IP restriction in Laravel Horizon and avoid 403 access denied error
I show you how to setup IP address restriction for Larvel Horizon and how to avoid the 403 error on...

Other Categories