Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

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 text or 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 to

In This Article

Bonus listings: 1 available