If I make the file name of each uploaded microtime () PHPs file, are the collision risks realistic? And is there a way to further randomize file names?
I expect about 20,000 downloads in about a week. This is 2800 / day or 119 / hour (subject to uniform distribution). Does anyone have experience suggesting that micro-time will be unique?
Thanks!
The best way to generate random file names in your case is to use a GUID . They are great because this algorithm guarantees the unification of values ββeven for multiple servers. If you use windows, the com_create_guid function is for you. You can also look at uniqid , which is available for all PHP platforms.
com_create_guid
uniqid
One common method is to create directories in the format YYYY / MM / DD / id.jpg. Thus, you also do not face file system limitations.
I think this is not a huuuuge problem. (paranoid view)
Just check if it exists, if it exists, resolve the conflict (possibly in a while loop until its unique is guaranteed).
I can not imagine so many files in a microsecond.