chitika Ad

Saturday, 1 March 2014

Storing Images in MySQL Revisited

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 textor varchar). Instead, we must use the blob type.
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 tohttp://dev.mysql.com/doc/refman/5.1/en/blob.html.

No comments:

Post a Comment