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 7160753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:27:00+00:00 2026-05-28T13:27:00+00:00

My question is not about storing images on disk or in DB. Images will

  • 0

My question is not about storing images on disk or in DB.

  • Images will be stored on disk
  • Image path and other image data will be saved in database.
  • Images will be given a unique filename
  • Images will be stored in 3 sizes
  • In time there may be many images used by many users

My questions are:
– Should images be stored in one folder, or many folders?
– Is it ok to use md5 for creating unique id’s? E.g. md5(id+filename+random_num)
– Should images be cached on server or on clients browser / computer?

Anything else I should think of?

The solution is using php, apache and mysql. We use Uploadify for uploading images.

Some code I use today

  /**
   * Calculate dir tree for object
   * Folders starts from 00 to FF (HEX) and can have just as
   * many subfolders (I think :)
   * @param $id - User ID
   * @param $type - Image category
   * @return string
   */
  function calculateDirTree($id, $type)
  {
      $hashUserID   = substr(hash('md5', $id), -4);
      $parentFolder = substr($hashUserID,0,2);
      $subfolder    = substr($hashUserID,2);    
      $basePath     = $type."/".$parentFolder.'/'.$subfolder.'/';

      return $basePath;
  }  
  • 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-05-28T13:27:00+00:00Added an answer on May 28, 2026 at 1:27 pm

    Should images be stored in one folder, or many folders?

    You are talking about “100k – 200k images” so many folders is a must have. Try to have max. ~1000 images in on folder.

    Is it ok to use md5 for creating unique id’s? E.g. md5(id+filename+random_num)

    Yes, you can do this. It will avoid problems with long filenames.

    Should images be cached on server or on clients browser / computer?

    The should be cached on the client side. The problem with so many images is that it creates high traffic. Caching on the client help reducing this.

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

Sidebar

Related Questions

I've read several questions about storing images in a database as opposed to folders
This is a general question about using Ajax on data that is not text/string.
This question is not about caching. I need this in-memory table for many small
My question is not about how to solve this error(I already solved it) but
This question is not about which is the best, it is about which makes
This question is not about 'best' barcode library recommendation, we use various products on
My question is not about a specific code snippet but more general, so please
(note that this question is not about CAS, it's about the May fail spuriously
For starters, this question is not so much about programming in the NetBeans IDE
This is not a question about a specific framework. I am using plain php

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.