|
Posted by Jared Williams on 03/30/05 21:02
> Sure, at the base level the issue is simply the uniqueness of
> the filename. So there are several options open in this
> regard. Either use an md5'd uniqid rand combination (as on
> the uniqid manual page) and just go with that, operating
> under the assumption that the chances of a conflicting hash
> are remote at best.
> Or another method (which the OP touched upon) would be using
> some SQL space and simply getting the next available ID back
> and using it as the filename. There are no race conditions
> here, the ID you will get is unique to that session. Assuming
> the site was correctly set-up you wouldn't then even need to
> check the file exists, just move_uploaded_file on it. But for
> the overly paranoid you could do and if a file does exist,
> get another ID. While it involves DB overhead it ensures
> relatively bullet-proof uniqueness and no warning generation
> / suppression.
I'll take absolutely bullet-proof and handled/supressed warnings, over relatively bullet-proof.
Jared
[Back to original message]
|