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

  • Home
  • SEARCH
  • 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 9149985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:33:07+00:00 2026-06-17T11:33:07+00:00

I am developing a social system where users can upload images. I am not

  • 0

I am developing a social system where users can upload images.

I am not very sure how I should structure my files. The two ideas I have is the following:

  1. Add a folder with the userID as name and put all the users images in there
  2. Have a single folder for all images, and give each image a unique name

Which one of the two would be better? Is it the proper way to organize images?

  • 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-17T11:33:08+00:00Added an answer on June 17, 2026 at 11:33 am

    It depends.

    When you use have a gallery with images stored in a directory per user, you also have to worry about duplicates (say user will upload several files with the same name).

    On the other hand in the first case you might run into performance issues related to number of files in a single directory (if you have more than 10k of files it might lag).

    Solution I like is is to create a unique name and crop it into several parts to create a directory structure.

    For example:

    1. Generate from a file image.jpg (look into the manual) a unique name, say
      nfsr53a5gb

    2. Add to it the original extension so it becomes nfsr53a5gb.jpg

    3. Split it with / into nf/sr/53/a5/gb.jpg

    4. Create missing folders as you go (see recursive parameter)

    You won’t hit the penalty for number of files in a directory soon and you won’t get a collision and files have URLs difficult to guess.

    A nice touch is to add a controller for getting those files which will change the name to the original name (store it in database and switch headers). Use it only for a dedicated download button as this might be too CPU and I/O intensive for many images embedded on a page.

    In order to do this you have to modify headers like this:

    Content-Disposition: attachment; filename=YOUR_FILE_NAME.YOUR_EXTENSION
    Content-Type: application/octet-stream
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a feature for my social networking website that allows users to
I am a Rails novice programmer. I am developing a social network.The system will
Developing a demo application. Error: Can not resolve properties under push tag. name and
I'm developing an iPhone app that can edit images. Ultimately, I want to have
How can I get a linebreak in TextBox in WP7? I'm developing social-based app(like
I'm developing an iOS social networking application that will involve users sharing and rating
I am developing a Ruby on Rails app that should have social authorizations (the
We are now developing a social news feed iOS app, and we need to
I am developing a social network for an intranet, and I came across a
I've been evaluating technology stack for developing a social network based application. Below are

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.