在 MySQL 数据库中存储图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18769978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:49:32  来源:igfitidea点击:

Store Images in MySQL Database

mysqldatabasefacebookfilersrc

提问by Zuckerberg MFSN

I want to know how to store images and files in a MySQL Database i want to get images and files like that www.example/rsrc.php/example-image.jpg

我想知道如何在 MySQL 数据库中存储图像和文件 我想获取像 www.example/rsrc.php/example-image.jpg 这样的图像和文件

example on Facebook: facebook-example.com/rsrc.php/v2/yw/r/svhh826BLKd.png

Facebook 上的示例:facebook-example.com/rsrc.php/v2/yw/r/svhh826BLKd.png

回答by johnny

Create a BLOB column in database table,

在数据库表中创建一个 BLOB 列,

probably mediumblob.

可能是mediumblob。

but it is good to keep the photo in directory and keep the path in the database. Cheers

但是最好将照片保存在目录中并将路径保存在数据库中。干杯

 CREATE TABLE tblname(ID INT,IMAGE BLOB);

INSERT INTO tblname(ID,IMAGE) VALUES(1,LOAD_FILE('C:/test.txt'));

added the answer from the comments to this question in the answer box..

在答案框中添加了对该问题的评论中的答案..