简体   繁体   中英

Saved images in Heroku app are not being displayed?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM