Upload image directly through mySQL Command Line

前端 未结 6 1094
春和景丽
春和景丽 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:41

    I recommend you to never upload images directly in a database, it's quite inefficient. It's better to simply store the location and name of the image and store those images in a folder somewhere.

    and if you want to "upload" via the commandline, you can just do an:

    insert into table(image_loc) values('/images/random/cool.jpg') where id=1;
    

    and depending on your environment you can use shell access to move images around. I'm not quite sure what you are trying to do with these images or how your system is setup. You'll probably need to clarify on that.

提交回复
热议问题