How to insert an image in MySQL?

1

I would like to add images to the table, nothing too complex.

  • I would like to add the directory if possible
  • This bank will not have an interface
  • I would like to see the image by select, but I do not think that is possible.

What do you guys think?

    
asked by anonymous 25.05.2014 / 21:14

1 answer

1

There are two common approaches to inserting an image into the database:

  • Save the image in a directory (eg, C:\imagens ) and in the database the name of the image file to fetch later.

  • The image itself is saved to the database using a column of type blob (binary).

  • In both cases no it is possible to view the image directly (via a select).

    In the second case you need to use a function / method that "converts" the binary image to file again, which makes everything harder to implement.

    Check out this question here: Is Wrong to write images byte in database?

        
    25.05.2014 / 21:51