Storing Images in MySQL Revisited
The Blob Data Type
Images are made up of binary data. This data cannot be stored in normal text fields in MySQL (such as
varchar). Instead, we must use the
This type - short for binary large object - is a type that can hold a variable amount of data. The four types of blobs are as follows:
tinyblob: about 256B
blob: about 65KB
mediumblob: about 16MB
longblob: about 4GB
The actual type you choose doesn't really matter, since it only stores as much data as you need. Therefore I'd recommend using the
longblob type. It's better to be prepared for files larger than 16MB than having to change the column later.
You can read more about blogs at the MySQL web site. Refer to http://dev.mysql.com/doc/refman/5.1/en/blob.html.