RE: [PHP] Re: Images in Mysql
| From: | joakim dot andersson at cybercom dot se | Date: | Wed, 10 Jul 2002 14:48:57 +0000 |
| Subject: | RE: [PHP] Re: Images in Mysql | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-106816@lists.php.net to get a copy of this message | ||
> Hi Asaf,
>
> Thanks for the advice. That sounds like a good solution. One
> thing I was
> wondering about is... when my PHP script saves the uploaded image to
> the web server, how should the image be named [uniquely]? The
> problem is
> that if the user specifes the name of the image file, there's
> a chance
> he'll name another one the same way (and thus overwrite the
> original). I
> was thinking of maybe a dual approach, where the user gives the image
> file a name, but then the PHP script appends, say, the table name and
> record ID--so as to make the filename unique.
>
> What do you think? Is that how you do it? (Or is there a better way??)
If you have a table that stores information about the images then I suggest
you use the record ID alone (with the correct file-extension) as a filename.
This will allways be unique, otherwise you probably have trouble with your
dB aswell...
This is how I do it.
Regards
Joakim Andersson