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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:14:50+00:00 2026-05-30T05:14:50+00:00

I’ve read several questions about storing images in a database as opposed to folders

  • 0

I’ve read several questions about storing images in a database as opposed to folders on the server, and I’ve decided to go with folders, but I’m wondering how clever I need to be. I’ve found a lot of questions about storing thousands of images, but I just want to store three images per user (really one image in three flavors).

In this question the questioner first proposes a directory structure based on username (which in his case and in mine is an e-mail address). His directories would look something like:

/images/domain.com/user/imagename.png

Would that be ok to use in my case? I am not an old hand at this so I’m wondering if there’s something I’m not thinking of in terms of security or performance that I should be concerned with. I’m hoping to keep all images in a folder outside the webroot, so I don’t think there’s an issue with users accessing files they aren’t entitled to see, but are there other reasons why you might want to take a hash of the file and use it to generate the directory structure or use some other sort of pseudo-randomly generated gobbledegook instead of part of a username to generate directory structure?

Edit: I am using php and the photos are just profile photos if that makes any difference. They are basically visible to any user when searching for other users, so when it comes to security, I just don’t want people to be able to hot link to a user’s photo or to navigate to the photo directly by typing in a url that leads to it. That is unless, as I said, there are other security concerns I should be thinking about but don’t know to think about.

  • 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-30T05:14:51+00:00Added an answer on May 30, 2026 at 5:14 am

    I don’t see why hashing the files would be of use unless you were expecting a good deal of them to be identical; then you could save lots of storage.

    If users will ever be able to edit their usernames (and you can’t tell the future!) then I wouldn’t use that in the structure. Use a database primary key or something which will never change.

    If you did want a bit more structure you could still split the ids across levels of structure, so for example: a user with an id 1234 would have images stored at:

    /images/domain.com/12/34/imagename.png
    

    Which would at least mean you didn’t have more than a hundred directories when you look at the list…

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.