Store a file in a database

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
Lord Sauron
Forum Commoner
Posts: 85
Joined: Tue Apr 20, 2004 5:53 am
Location: Tilburg, NL

Store a file in a database

Post by Lord Sauron »

Hi there,

Can someone please tell me, what type a database attribute should be of, when I'm trying to store a file in database. And what default value it should have.

Can I use the same type for any kind of file, or is maybe a different type necessary for .zip or .exe file?

Thanks in advance for the answer,

Antonie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

meet MEDIUMBLOB, and it's siblings, LONGBLOB and BLOB
User avatar
Lord Sauron
Forum Commoner
Posts: 85
Joined: Tue Apr 20, 2004 5:53 am
Location: Tilburg, NL

Not only for images

Post by Lord Sauron »

I though blob was only used for storing images, but I guess I was wrong ;-)

Okay, thanks.

By the way, when do you use longblob, mediumblob and blob? I there a certain size of the attachment required?

And I guess default value should be null?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the blob brothers are for binary data.. so yeah..
longblob has a maximum length of 4GB, mediumblob 16MB, blob 64K, and tinyblob 255 bytes.
Post Reply