Re: Images in DB
| From: | Rosenet Technical Support | Date: | Wed, 12 Jul 2000 00:58:21 +0000 |
| Subject: | Re: Images in DB | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1056@lists.php.net to get a copy of this message | ||
Nam Nguyen pressed the little lettered thingies in this order...
>
> I'm not sure why you want to store images in mysql. but we don't
> search the binary text, so should we just put images in a directory
> and only put the image path in mysql?
>
> Nam.
>
Actually, you don't even have to put the path into MySQL. We do
one of two things:
1) Create directories with permissions that allow PHP to upload
files. When people submit information into their database, the
item's unique ID is extracted and the image is placed into the
special directory and renamed with the unique ID (an image for
product number 123 would be 123.jpg).
2) Keep all of the images in one directory on the server and store
only the file name in the database.
When you do either of these, you can use PHP's file_exists()
function rather than relying on the database.
http://www.php.net/manual/function.file-exists.php
This has worked much better for us than storing full paths or binary
data in the database because you can remove images from the
server without altering the database.
YMMV...
Christopher Ostmo
a.k.a. support@rosenet.net
Rosenet, Inc.
For a good time,
http://modems.rosenet.net/mysql/