Skip to main content
Dec 12, 2009 5:19 PM UTC
Question

Best data type in mySQL for an Image

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 is closed to new replies. Start a new post to keep the conversation going.

    6 replies

    Jul 21, 2010 8:31 AM UTC

    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

    Translate
    Jul 15, 2010 5:24 PM UTC

    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

    Translate
    Known Participant
    Jul 15, 2010 5:28 PM UTC

    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

    Translate
    Known Participant
    Jul 15, 2010 12:30 PM UTC

    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?

    Translate
    Dec 12, 2009 6:18 PM UTC

    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

    Translate
    Bogdan Manate
    Participant
    Dec 12, 2009 5:29 PM UTC

    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.

    Translate