Strategy for storing pictures separate from the software files

Hello, I have a user-friendly post editor in my web site using TinyEditor or CK Editor. I want to add an option in which the user can upload pictures to the system and put it on the post.

I don’t want to store the pictures in the website directory because they are not part of the website software data (PHP files, CSS, etc…). If I replace the website directory with a new version, I have to be careful for not deleting the pictures accidentally.
I could store the pictures into the database, but it is weird and may have performance issues.

What is a good strategy for storing pictures related to content data (posts)?

@virtualavatar. What do you mean with:

Those pictures are related to a certain post, right? I don’t know what your database structure is right now but I would create a table post_photos and have a foreign key in this table “post_id” which is related to a post with that id, if that is what you mean?

The easiest way would be to store them in a CDN, like Amazon S3, Google Cloud Storage, etc. Then in the database store the URL to the CDN and use that URL in your website to link to the images.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.