Adding an image to a database table?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Adding an image to a database table?

Post by cturner »

Can someone please tell me what data type I should use to add an image to a database? Thanks in advance.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Adding an image to a database table?

Post by Zoxive »

cturner wrote:Can someone please tell me what data type I should use to add an image to a database? Thanks in advance.
Images in databases, are NOT recommended, and I'm pretty sure its Blob, if you still continue on with it...

-NSF
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

You would be better off storing the file somewhere on disk and just inserting the filename (or path and filename) into the database...
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Post by cturner »

Why aren't images in databases recommended? How can I show an image for each product when there are a lot of images to be displayed? I have tried BLOB and nothing is displaying.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

cturner wrote:Why aren't images in databases recommended? How can I show an image for each product when there are a lot of images to be displayed? I have tried BLOB and nothing is displaying.
Why? its been said many times, and instead of explaining again.....

viewtopic.php?t=46301&highlight=image+database
feyd wrote: But it is not recommended. Why? In order to display the image, you'll have to make a reference to a PHP script as the image. This reference will need to query and extract the binary data from the database server. This causes more server load than is necessary. Instead, it is often suggested to use the filesystem to store the files. That's what it's built for.

If you want to read previous threads on this, use the search *blob* as the keyword string (with the both asterix)
viewtopic.php?t=37077

-NSF
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Post by cturner »

What data type should I use to store a filename in a database?
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Post by emmbec »

I sugest to store the name as a VARCHAR, you also need the TYPE (also as VARCHAR) and you may want to store the size as an INT.
jftuga
Forum Newbie
Posts: 9
Joined: Tue Feb 14, 2006 1:13 pm
Location: Athens, GA

Post by jftuga »

Our software vendor has decided to store images inside the database. The 270,000 images consume 72 gigs. When this file changes, the whole file needs to be backed up and 3 days of backups are stored. If the vendor had decided to store images on the filesystem, then incremental backups would be much easier as the database would be much smaller in size. I hope this database file never get corrupted. :?

-John
Post Reply