Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert image in mysql database(table)?

I want to insert image into a table like

 CREATE TABLE XX_SAMPLE(ID INT
                       ,IMAGE BLOB);

So can you help out form how to insert image into the above table.

like image 561
Viru Avatar asked Feb 05 '13 09:02

Viru


2 Answers

Please try below code

INSERT INTO xx_BLOB(ID,IMAGE) VALUES(1,LOAD_FILE('E:/Images/jack.jpg')); 
like image 111
Madhav Avatar answered Sep 21 '22 13:09

Madhav


You should use LOAD_FILE like so:

LOAD_FILE('/some/path/image.png')
like image 22
Ivaylo Strandjev Avatar answered Sep 22 '22 13:09

Ivaylo Strandjev