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

The Archive Base Latest Questions

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

I am making a website which allows users to upload images for their profiles.

  • 0

I am making a website which allows users to upload images for their profiles. I would like to know which of these would be the better route to take (The file names in all these cases would be a randomly generated string):

  1. Have all the files be saves in a single folder called uploads

  2. Create a folder named after the numeric user id of the user and place all of their images in their own folder. Each time they upload a new image I would check to see (using PHP) if the folder named after their id exists and if so not make a new dir and just put the images in the existent one

  3. Same as #2 but don’t check to see if a folder exists named after the user id, PHP or Linux seems to know not to make one if one already exists and use the one that does.

  4. Something better

So which would these would be better from a performance perspective. I am really concerned about speed here. If I have hundreds of thousands of images all in one folder it seems like retrieving one among many would take quite some time. And I’m not sure if organizing them into sub folders would make things better.

  • 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:49:52+00:00Added an answer on May 28, 2026 at 1:49 pm

    I use the following structure:

    /**
       * 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;
      }  
    

    Looks like others also find this way a good way.

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

Sidebar

Related Questions

So I'm making a website that allows users to build contact lists. So their
I'm making a website which allows people to upload files, html pages, etc... Now
i have a website which i want my users to access from their iphones
For school I'm making this website which is a look-a-like of twitter. Now I
im making a website (wordpress multisite) which is supported by 2 languages for users,
I have my first professional assignment of making a website in which a photographer's
Hi i am making asp.net website and i am following SDLC Straitegy so which
I'm making a website that mail users when a movie or a pc game
I would like to allow my users to see other users data. I am
I have a web-site based on PHP, to which I would like to add

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.