Reputation: 13
I am new to web development and I have just deployed my site using Heroku. I am using Laravel as the framework and Postgres as the database.
In my site, I have a feature of storing images in my public/images folder. If I saved the images and changed the file permissions before deploying it on Heroku then the images are being displayed. However, if the images are uploaded directly through Heroku, the images won't be displayed.
I am guessing this is caused by file permissions. Maybe because the images that are being uploaded in the public/images folder in Heroku is not inheriting the permission of the folder?
Upvotes: 1
Views: 3228
Reputation: 2887
The file system on Heroku is not persistent. You can't save files on the web server file system, and expect those files to be available for subsequent HTTP requests.
You need to use another persistence store, like storing those files on AWS S3 or in your database. There are also probably other addons that would allow you to save files simply enough.
Ref: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
Here's an example of saving and displaying images from a Postgresql database: Upload/Download file in POSTGRESQL database with PHP
Upvotes: 3