Upload image directly through mySQL Command Line

前端 未结 6 1084
春和景丽
春和景丽 2020-12-18 19:12

I have a certain table in mySQL which has a field called \"image\" with a datatype of \"BLOB\". I was wondering if it is possible to upload an image in that field directly f

6条回答
  •  春和景丽
    2020-12-18 19:44

    Sometimes we try to upload file using loadfile but file is not loaded or file path in formatted text is stored in BLOB field. This is because of access issues. If you are facing such condition, instead of loading file from any location, try to load it from data path of mysql preferably like :

    INSERT INTO `srms`.`images` (`ID`, `Image`) VALUES ('5', load_file('C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\test.jpg'));
    

提交回复
热议问题