Custom Fields
Re-Envisioned
Support MB Custom Table How to save image data using custom tables?

This topic contains 3 replies, has 2 voices, and was last updated by  Anh Tran 6 months, 3 weeks ago.

  • Creator
    Topic
  • #10669
    Resolved
    makeagency
    Participant

    Hi,

    There isn’t any documentation covering each of the fields using custom tables and was wondering how to store image data?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #10679

    Anh Tran
    Keymaster

    Hi,

    Each custom field value is saved in a corresponding column. The field ID = column name.

    What image data do you want to store?

    #10685

    makeagency
    Participant

    Hi,

    So for example:

    
    MB_Custom_Table_API::create( 'my_custom_table', array(
        'address' => 'TEXT NOT NULL',
        'phone'   => 'TEXT NOT NULL',
        'email'   => 'TEXT NOT NULL',
    ) );
    
    

    Would we use 'TEXT NOT NULL' for an image?

    #10687

    Anh Tran
    Keymaster

    I got it. You still can save image in the database by encoding it. Use a tool like this, or base64_encode function to convert the image file into a text string. Then you can save it. However, you need to handle outputting the image by decoding it, because the value stored is the encoded data, not the real image.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.