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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:03:41+00:00 2026-06-02T20:03:41+00:00

Context: I’ve just written a PHP file upload handler that saves any incoming file

  • 0

Context:

I’ve just written a PHP file upload handler that saves any incoming file to my site’s upload directory.
The upload directory is publicly accessible through the web, and currently each file is just dumped straight into it after being renamed with a unique ID generated by the database.
The hander will allow any file type aside from JS and PHP, not just images.
Number of files likely to be in the thousands eventually but it will take a couple of years for that to happen.

My question:

Is it a good or bad idea to have all uploaded files in the same directory on the server, and if not please explain why, and what would be better approach?

I notice that wordpress stores them in directories named for the date for instance.

The only real downside I can see is that an ls on the directory might be resource intensive once there are a few thousand files in there.
Or is there limits placed on number of files in one dir, or total size of one dir (running Linux)?

slightly preemptive note about security:

The upload handler is secured against anyone but logged in administrator level users uploading files, and it also won’t save PHP or JS files (atleast as far as I can reliably test for them using the type attribute in the $_FILES array) as these may be executed by the server. Another safeguard I plan to implement is an .htaccess file that blocks requests to certain filetypes, just incase. Any notes on this aspect would also be welcome but it’s not part of this question.

  • 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-02T20:03:43+00:00Added an answer on June 2, 2026 at 8:03 pm

    There is no set standard when it comes to organizing files. However, it’s not a good idea to put all the files in one directory. It’ll eventually start affecting the performance of the system, especially when it comes to indexing.

    You can do what WordPress does, organize by year, month, and date. You can maybe also organize by filetype (extension), so have a PDF directory, an ZIP directory and so on, with maybe year/month/day directories in them for further classification.

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

Sidebar

Related Questions

Context: I setup a photo upload that uses an iframe to upload the image,
Context: I'm building a little site that reads an rss feed, and updates/checks the
Context is C#,.Net framework. Is it the application that runs without any need to
Context: I need to develop a monitoring server that monitors some of our applications
Context We have a SharePoint site set up on a Windows Server 2008 VM
Context In our application, we snapshot data from a database using a query that
Context I have a tree view with folders ( .directory ): When I mouseover
Context: The structure of the code is that a WCF service (server-size) talks to
Context I use FINDSTR /C:portid= scanports.xml to extract theses lines from a file: <port
Context I realized that in Twitter , the profile page is displayed in different

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.