照片存储在数据库中或作为文件 [英] photos stored in database or as files

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

问题描述

大家好!


我有一个问题。


我想创建照片库。


我想知道我是否应该将照片(用户上传)存储在数据库中


$ data = file_get_contents($ _ FILES [''photo''] ['' tmp_name'']);

$ data = mysql_real_escape_string($ data);

//准备在MySQL查询中使用的数据


mysql_query(" INSERT INTO {$ table}

SET ext =''$ ext'',title =''$ title'',

data = ''$ data''");


$ msg =''成功:图片上传'';


或我应该存储上传照片文件作为服务器文件夹中的文件?


几年前,在我之前的工作中,我在MS Access应用程序中工作,而

在我看来存储照片在这个数据库中都不是那么好,因为上传了



存储在MS Access应用程序中的照片文件,放大了几个数据库

时间。

这就是为什么在数据库中存储这些文件并不那么相关而且更好

方式

是将这些文件保存在指定的文件夹。

Mysql怎么样?


你能告诉我你的意见吗?

M.

Hello all!

I have a question to you.

I would like to create photo gallery.

I wonder if I should store photos (uploaded by users) in database

$data = file_get_contents($_FILES[''photo''][''tmp_name'']);
$data = mysql_real_escape_string($data);
// Preparing data to be used in MySQL query

mysql_query("INSERT INTO {$table}
SET ext=''$ext'', title=''$title'',
data=''$data''");

$msg = ''Success: image uploaded'';

or I should store uploaded photo files as files in the server folder?

Few years ago in my previous work I worked in MS Access application, and
in my opinion storing photos in this database are not so good, becuase
uploaded
photo files stored in MS Access application, enlarged the database a few
times.
That`s why storing such files in database is not so relevant and the better
way
was to saved these files in the specified folder.
What about Mysql?

Could you give me your opinions?
M.

推荐答案

data = file_get_contents(
data = file_get_contents(


_FILES [''photo''] [''tmp_name'']);
_FILES[''photo''][''tmp_name'']);


data = mysql_real_escape_string(
data = mysql_real_escape_string(


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

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