How to insert image in mysql database(table)?

后端 未结 8 1995
野趣味
野趣味 2020-12-13 05:08

I want to insert image into a table like

 CREATE TABLE XX_SAMPLE(ID INT
                       ,IMAGE BLOB);

So can you help out form how t

8条回答
  •  自闭症患者
    2020-12-13 05:43

    I tried all above solution and fail, it just added a null file to the DB.

    However, I was able to get it done by moving the image(fileName.jpg) file first in to below folder(in my case) C:\ProgramData\MySQL\MySQL Server 5.7\Uploads and then I executed below command and it works for me,

    INSERT INTO xx_BLOB(ID,IMAGE) VALUES(1,LOAD_FILE('C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/fileName.jpg'));
    

    Hope this helps.

提交回复
热议问题