Skip to main content
December 12, 2009
Question

Best data type in mySQL for an Image

  • December 12, 2009
  • 5 replies
  • 13883 views

What would be the preferred data type in mySQL to store an image

(jpeg or png)?

I would think BLOB would serve this purpose best.

Who is currently doing this and what data type are you using?

Regards,

Scott

    This topic has been closed for replies.

    5 replies

    July 21, 2010

    Hi GIlly,

    thanks for taking the time to reply to this (old) post. The problem, of saving images to

    MySQL is still hounding me.

    I bought a package from the Flex Application Store to handle  the MySQL interface

    which works most of the time. So, unfortunately I am pretty ignorant of PHP and can't

    fathom just what in your code solves the problem.

    Regards,

    Scott

    July 15, 2010

    Hi GIlly,

    well, we all agreed that the best field type in which to store the image

    would me a blob. I still have not succeeded in storing an actual image

    in  MySQL database (see my post of July 4th).

    UbuntuPenguin has been giving me some ideas but  I can't get

    an image written to the DB. The trick is to encode the image into

    a byteArray and I have code for that and for the decode of the

    image when reading from the database.

    If you take the encoded byteArray and copy it by hand into a blob

    field in MySQL every thing is fine. I just can't get an HTTP service

    call to do it.

    Regards,

    Scott

    Known Participant
    July 15, 2010

    Hi Scott

    I have literally this very moment cracked it!!

    my posting on the forum is at

    http://forums.adobe.com/message/2975781#2975781

    it might help if you are still looking to do it.

    Best wishes

    Gilly

    Known Participant
    July 15, 2010

    Hi Scott

    I wondered if you got this working,  I am trying to use mysql to store images in and the retrieve but I can upload but am being unable to view in the browser I am just getting the raw data,  have tried a proxy script am still not getting it working?

    December 12, 2009

    Hi Bogdan,

    I was eying MEDIUMBLOB as the data type.

    BLOB values are treated as binary        strings (byte strings) in mySQL and

    I just wanted to know if BLOB is in principle the best container for

    a jpeg image in mySQL.

    Scott

    Bogdan Manate
    New Participant
    December 12, 2009

    Depends on your images sizes.

    BLOB = 65KB

    MEDIUMBLOB =  16MB.

    LONGBLOB = 4GB.

    I think you can use mediumblob, but you know best the maximum size of

    a picture.