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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:06:14+00:00 2026-05-26T03:06:14+00:00

I guess I have 2 approaches to store images in a php application: either

  • 0

I guess I have 2 approaches to store images in a php application: either to store them in a database or to a folder with unique names. Considering that I want to minimize the database connections, how can I secure a folder that has images uploaded by the users?

So basically, each user will have a profile and will upload their photos to the website to share them with whoever they want. I plan to store them as follows:

/root/somefolder/{userid}{uniquenumber}.jpg

If I configure the htaccess to prevent access to the current folder, will it be enough? Or should I have some other security precautions?

Cheers

  • 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-26T03:06:14+00:00Added an answer on May 26, 2026 at 3:06 am

    Either to store them in a database or to a folder with unique name

    Databases are optimized for storing small pieces of data rather than big blobs. You’ll get better performance if you let the normal OS and web server handle file delivery. Using normal files saves you from having to re-implement handling of HTTP cache headers and range requests too.

    But either way, these resources need URLs, so the second part of your question is still relevant.

    If I configure the htaccess to prevent access to the current folder, will it be enough?

    I should think that will be enough. As long as the unique part is long (e.g., “somefolder/738b3093b898654bd3bbb9e3770e7fc0.jpg”) and doesn’t follow a pattern there is no way to guess it.

    But unless you really need the userid in the file name, avoid it. Facebook includes the user profile ID is part of the photo file name, so when people share the photo files somewhere else it allows discovery of their Facebook profile and real name. I’ve seen it cause stalking and harrassment in multiple online communities. It’s not the user’s fault — they have no idea they’re giving away their real name or friend’s real name by posting a photo somewhere.

    Another consideration is that as such a system grows and it gets a massive number of files, it’s an awful burden on the file system if they’re in just one folder. You can prevent that easily by repeating or splitting part of the name in subfolders. E.g., “somefolder/7e/7e8b3093b898654bd3bbb9e3770e7fc0.jpg”.

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

Sidebar

Related Questions

We have an existing application that runs on php and mysql. We are in
I note that Scheme and Lisp (I guess) support circular lists, and I have
I want to create an application that logs when I have gone jogging and
For typical 3-tiered application, I have seen that in many cases they use a
I have a working process, behind a web application, that is generating some records
I have a small application that process a large quantity of (relatively small) files.
I have a simple MySQL script that I use in a web application to
I have a MarshalByRefObject which I needed to serialize and store (in a database),
I am making a synonyms list that I will store it in database and
I guess I have been using the Web Site model ever since .NET 2.0

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.