将图像存储在MySQL数据库中 [英] Store Images in MySQL Database

查看:382
本文介绍了将图像存储在MySQL数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

推荐答案

在数据库表中创建BLOB列

Create a BLOB column in database table,

可能是mediumblob。

probably mediumblob.

以保持照片在目录中并保持数据库中的路径。 Cheers

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..

这篇关于将图像存储在MySQL数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆