Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8145215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:35:35+00:00 2026-06-06T13:35:35+00:00

A quick question on best practice for handling images in a PHP/MySQL CMS. Each

  • 0

A quick question on best practice for handling images in a PHP/MySQL CMS. Each item will have a varying number of associated images which will be stored in folders referenced by the items ID. Validation is done on upload so all files should be valid.
My question is whether I should also store the ID and filename(s) in a database table and pull the source data from the DB or is it OK to simply iterate through the folder and insert the source filenames directly?

I hope that makes sense. Thanks in advance for any advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:35:37+00:00Added an answer on June 6, 2026 at 1:35 pm

    It largely depends on how many points of failure you want and the speed of the response time.

    If you store it on the filesystem:

    1. Incoming HTTP request
    2. PHP queries the database
    3. The database finds the row
    4. PHP deciphers the query response
    5. PHP reads the file
    6. PHP sends the file’s binary contents as a response to the HTTP request

    However, if you store it as a binary blob in a database:

    1. Incoming HTTP request
    2. PHP queries the database
    3. The database finds the row
    4. PHP deciphers the query response
    5. PHP sends the binary contents as a response to the HTTP request

    In both cases step 3 (the database finds the row) can be just as fast with our WITHOUT the blob column as long as proper indices/keys are set up. MySQL will move the pointer to the exact indexed position internally – it won’t actually go through every byte until it finds the right one (that’s the whole point of an index). This is just as time consuming as PHP reading the file manually. However, I currently do not have supporting performance data to support this.

    Now let me talk about points of failiure:

    • Let’s say you migrate your data. If your binary image data is stored in the database, you just move the database. However, if your binary image data is stored on the file system, you have to remember to move both. Also note that the SIZE of the migration would be identical (or at least minimally different).
    • Consider renaming an asset – you’ll have to rename it not only in the database, but also on the file system. That’s 2 total steps as opposed to renaming it in the DB which is only 1.
    • Consider deleting the asset – you’ll have to delete it in both locations.

    I have always stored binary data as a blob in the database for the purpose of portability, flexibility, and minimizing failure or corruption.

    If you choose to store the file in the database as a blob, consider the different blob storage requirements: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html#id656744

    • TINYBLOB – 256 bytes
    • MEDIUMBLOB – 64 kilobytes
    • LONGBLOB – 4 gigabytes

    Lastly, just food for thought:
    I have experience working with Adobe’s Day CQ which is an up-and-coming enterprise-level content management system. It is primarily written in Java, but what is important to note is the data architecture. It uses a JCR (Java Content Repository) which more or less acts like a multidimensional MySQL database (kinda cool?). All image data in its DAM (digital asset manager) is stored as a node within the JCR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quick question about best practice with PHP classes. I have seen people use
I just have a quick best practice question regarding custom cells in a UITableView.
Quick question on best practice. I have an AJAX application where there are 4
I have a quick question on best practice and if getters and setters are
I have a quick question - is there a best practice in SQL Table
Just a quick question about best practice in MVC development. Let's say that I've
Have a quick question about what would be the best way to implement iterators
Quick question on what is the best practice for integrating with external systems. We
I have read the following question Javascript and Anchor Tags, Best Practice? And it
a quick, probably easy question whose answer is probably best practice I'm following a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.