Reputation: 30421
I've created my first site with an image uploading feature and this just crossed my mind. Is ['tmp_name']
in $_FILES
a unique value like in uniqid()
?
Upvotes: 0
Views: 1246
Reputation: 324640
It's unique in that you can never have two files with the same name at any given time. However since the files are temporary they will most likely be deleted shortly after their creation, so the filenames free up again.
Upvotes: 1
Reputation: 20997
It's unique for the time being. As soon as you delete it (it should be deleted automatically when the script finishes) some file may and eventually will get the same name. PHP manual doesn't say that tmp_name
is unique, so simplified answer is no, it isn't.
Upvotes: 4
Reputation: 4397
Yes, PHP generates this to uniquely name an uploaded file. You can't guarantee the file will stay around forever depending on where it's stored to. Often it's /var/tmp
Upvotes: 1