Re: asking comment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux