You are here: Re[4]: [PHP] asking comment « PHP « IT news, forums, messages
Re[4]: [PHP] asking comment

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация