|
Posted by Richard Davey on 03/30/05 20:39
Hello Jared,
Wednesday, March 30, 2005, 6:27:14 PM, you wrote:
JW> If you think you have another method please elaborate.
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.
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov
[Back to original message]
|