将图像保存在数据库mysql中 [英] Saving images in database mysql

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

问题描述

我的客户端在php + mysql中创建了一个脚本,可以将图像直接保存在数据库中,每个图像都有以下网址:www.example.com/image.php?id=421

My client have created a script in php+mysql that saves images directly in the database and every images has url like this: www.example.com/image.php?id=421

在你看来这是一个非常错误的解决方案?

In your opinion this is a very wrong solution ? Should I rebuild all the site ?

每天大约有1000次访问,数据库中有大约600张图片。

There are about 1000 visits per day and about 600 images in the database.

推荐答案

图像文件是文件,除非有令人信服的理由将它们存储在数据库中,它们所属的位置是文件系统,您可以在其中获得容易的备份和复制,由web服务器直接服务的多个机器以及由web服务器支持的所有最后修改日期和etag以实现更好的性能等。

Images files are files, unless there is compelling reason to store them in the database, the place they belong is the file system, where you get benefits like easy backup and replication, distributed across multiple machines, directly served by the webserver, and all the last-modified-date and etag supported by the webserver to achieve better performance, etc.

如果图像的数量预期将在未来版本中创建不同大小的一个图像(例如缩略图等),强烈建议将图像从db迁移到文件系统的计划。

if the number of images is expected to grow, and different sizes of one image are expected to be created (e.g. thumbnail images etc.) in the coming release, a plan to migrate images from db to file system is strongly suggested.

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

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