While uploading new photos to a linux server with PHP, I'm having to give them unique names (using it's file name is ruled out). There's no interaction with a DB so getting unique IDs is also not possible.
I thought of using DATE+TIME.jpg, but that's just too long.
So what is the best method to create the shortest possible unique names with PHP?
Use tempnam().
$filename = tempnam ($dir, $prefix)
It creates a file with a unique name in the specified directory. The generated file name is pretty short and guaranteed to be unique.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With