Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best method to generate unique filenames when uploading files PHP [duplicate]

Can any one suggest the best practice to generate unique file names for file uploads to avoid duplicate Entries?

Thanks In Advance.

like image 753
Adamski Avatar asked Dec 06 '10 23:12

Adamski


People also ask

How to generate unique filename in PHP?

I usually either create a UID using uniqid() function for the filename or create a folder with the name of the username who is uploading the file and leave the original filename. The disadvantage of the first one is that you will have to save the original filename somewhere to show to the user.


1 Answers

I usually either create a UID using uniqid() function for the filename or create a folder with the name of the username who is uploading the file and leave the original filename. The disadvantage of the first one is that you will have to save the original filename somewhere to show to the user.

like image 131
ryudice Avatar answered Sep 24 '22 10:09

ryudice