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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:32:46+00:00 2026-05-27T17:32:46+00:00

Possible Duplicate: Unique key generation How to automaticly make a new name of file

  • 0

Possible Duplicate:
Unique key generation

How to automaticly make a new name of file when you upload it to server?

I upload a picture file with < input type=”file” / >. File has name picture_1.jpg. But I’d like to store it in filesystem with name like this ec0b4c5173809b6aa534631f3207.jpg? How such new names are created? Is some special script/generator used to make such names?

For example picture in FB: http:// a3.sphotos.ak.fbcdn.net/hphotos-ak-snc6/190074_10150167009837952_8062627951_8311631_4439729_n.jpg.

The name of it is 190074_10150167009837952_8062627951_8311631_4439729_n.jpg. But original name was different for sure. So I’d like to change the name of uploaded file the same way. How is it possible?

  • 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-27T17:32:47+00:00Added an answer on May 27, 2026 at 5:32 pm

    In PHP I use uniqid() for naming files that I store from uploads

    If you want an extra long or seemingly more random id, you can sha1() or md5() the uniqid to create a hash.

    You could of course also use those two methods to create a hash of the filename.

    For example, the following code can be used to generate a new name for a file

    $file = 'somefile.jpg';
    $new_name = uniqid();
    $new_name .= '.'.pathinfo($file,PATHINFO_EXTENSION);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Specifying an index (non unique key) using JPA Is there a way
Possible Duplicate: Unique random numbers in O(1)? How do I fill an integer array
Possible Duplicate: Which collection for storing unique strings? I am currently using a Dictionary<string,
Possible Duplicate: What structure type do I use for HTML content (MySQL) What's the
Possible Duplicate: Relational database design question - Surrogate-key or Natural-key? When I create relational
Possible Duplicate: How do I define a unique property for a Model in Google
Possible Duplicate: How to generate 8 bytes unique id from GUID? I need a
Possible Duplicate: Generate a unique value for a combination of two numbers Is there
Possible Duplicate: Is a GUID unique 100% of the time? Simple proof that GUID
Possible Duplicate: Returning unique_ptr from functions 20.7.1.2 [unique.ptr.single] defines copy constructor like this :

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.