The kneejerk response always seems to be #2, store images in the filesystem
and store their paths in the database.
I like to compromise: store the original image in a dedicated image data
table in the database (keep a separate table for image meta data
(date/title/category/whatever) for faster queries, link the two with an
'image_id' field), then have the script which displays the image check for a
copy in a specified directory in the filesystem; if it's not there, yank a
copy from the database, resize/watermark as needed, and store in the
directory. Otherwise, the script can just write the img href on the fly.
This way you don't wind up with the overhead of pulling images from the DB
on the fly every time (just the first time a script looks for the image),
but you maintain a pristine copy of the original image in the database-
especially nice for uploading photos straight out of a digital camera
without monkeying around in Photoshop/GIMP; you get the web-sized copy in
your /images directory, but you keep the full resolution copy in the db if
you ever need it for something else. And if you ever need to move the db to
a new server, you don't need to worry about moving all the image files
separately.
I suppose storage space might become a factor if the number of images
climbed into the high hundreds or thousands, but it works great for me in
smaller applications. YMMV, caveat emptor, etc.
-Andy
-Original Message-
From: Clever [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 3:35 AM
To: [EMAIL PROTECTED]
Subject: Images on MySQL
Hi,
I'm designing a site and I have to store a lot of images.
Which is the best for speed?
1) Store all images on a MySQL table?
2) Save them on disk like normal files and only have pointers to
them on the
database?
Thanks a lot
Clever Anjos
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php