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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:14:56+00:00 2026-05-25T18:14:56+00:00

I have a topic/question concerning your upload filename standards, if any, that you are

  • 0

I have a topic/question concerning your upload filename standards, if any, that you are using. Imagine you have an application that allows many types of documents to be uploaded to your server and placed into a directory. Perhaps the same document could even be uploaded twice. Usually, you have to make some kind of unique filename adjustment when saving the document. Assume it is saved in a directory, not saved directly into a database. Of course, the Meta Data would probably need to be saved into the database. Perhaps the typical PHP upload methods could be the application used; simple enough to do.

Possible Filenaming Standard:

1.) Append the document filename with a unique id: image.png changed to image_20110924_ahd74vdjd3.png

2.) Perhaps use a UUID/GUID and store the actual file type (meta) in a database: 2dea72e0-a341-11e0-bdc3-721d3cd780fb

3.) Perhaps a combination: image_2dea72e0-a341-11e0-bdc3-721d3cd780fb.png

Can you recommend a good standard approach?
Thanks, Jeff

  • 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-25T18:14:57+00:00Added an answer on May 25, 2026 at 6:14 pm

    I always just hash the file using md5() or sha1() and use that as a filename.

    E.g.

    3059e384f1edbacc3a66e35d8a4b88e5.ext

    And I would save the original filename in the database may I ever need it.

    This will make the filename unique AND it makes sure you don’t have the same file multiple times on your server (since they would have the same hash).

    EDIT

    As you can see I had some discussion with zerkms about my solution and he raised some valid points.

    I would always serve the file through PHP instead of letting user download them directly.

    This has some advantages:

    1. I would add records into the database if users upload a file. This would contain the user who uploaded the file, the original filename and tha hash of the file.
    2. If a user wants to delete a file you just delete the record of the user with that file.
    3. If no more users has the file after delete you can delete the file itself (or keep it anyway).
    4. You should not keep the files somewhere in the document root, but rather somewhere else where it isn’t accessible by the public and serve the file using PHP to the user.

    A disadvantage as zerkms has pointed out is that serving files through PHP is more resource consuming, although I find the advantages to be worth the extra resources.

    Another thing zerkms has pointed out is that the extension isn’t really needed when saving the file as hash (since it already is in the database), but I always like to know what kind of files are in the directory by simply doing a ls -la for example. However again it isn’t really necessarily.

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

Sidebar

Related Questions

I have the tables question, topic and question_has_topic (many-to-many relationship). In my application admins
My DB have two tables - Question and Topic. To implement many-to-many relation, there
I have a question concerning about application testing coupled with external interfaces (REST -
I have tried looking though several of the already asked question about this topic
Ok, I have done plenty of research on this topic before asking the question,
There are several other questions about this topic that I have gone through, but
I have a Topic model and a Post model. A Topic has many Posts,
I have many Topic objects and each Topic hasMany posts:Post How can I order
I have a local topic branch that's tracking a remote branch. For the sake
I'm new to flex and I have a question concerning bitmapData and its width

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.