Reply to Re: [PHP] asking comment

Your name:

Reply:


Posted by Richard Davey on 03/30/05 15:58

Hello William,

Wednesday, March 30, 2005, 1:44:01 PM, you wrote:

WS> Is there a so sort of a problem here that I am not thinking of? I
WS> only can imagine problem that the rand() gives the same value
WS> twice. But I cant see this as a major problem because there would
WS> be maybe not more than 1000 uploaded pictures. So the chance is at
WS> worst something like 1:10 000 that same name is created to the
WS> image.

Actually that's only true of the very first image you upload. For
every image uploaded there-after your odds get worse and worse for a
conflict happening.

If you really must use this method please at least do a file_exists()
check first to make sure your random number hasn't been used.

WS> Anyway if same name is created what's the best way to check that?

Depends how you are storing it - if it's in a database then check to
see if that ID is used. If just a plain file, use file_exists.

WS> I was thinking of putting the image name field in DB as a unique
WS> field. That would do it? Right?

Yes it would ensure the filename was unique, but unless you actually
need it in a database it's probably not worth the effort. Just check
for the actual file itself.

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]


Удаленная работа для программистов  •  Как заработать на 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

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