java - 关于图片,视频等保存数据库的问题,谢谢
高洛峰
高洛峰 2017-04-17 17:43:55
0
6
460

1.以前我咨询过一些前辈,他们说将图片和视频以文件形式保存在服务器上比较好(一般会腾出一台专门放上传文件的服务器),因为数据库写入写出太消耗资源。

2.那我想问下如果有一天用户突然要迁移项目到另一台服务器,比如原来的服务器,图片都是存放在D://pic//目录下,然而新的服务器没有D://盘符怎么办?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(6)
巴扎黑

The database generally stores the path of resources. Relative paths are generally used in projects. Absolute paths should be rarely used. If you use relative paths, there will be basically no problems with project migration.

伊谢尔伦

Image and video resources are placed on separate servers and accessed using separate domain names, such as img.xxx.com, so migrating the server will not affect it. Even if the path changes, it can be rewritten with rewrite.

小葫芦

It must be a separate server. The database stores links. If the value of a certain field in the database is too large, it will affect the query efficiency of the entire table.

PHPzhong

1. As long as the directory structure does not change, it should be easy to change the path;
2. For pictures that are accessed frequently and can be made public, it is recommended to use storage services such as Qiniu. This will reduce server pressure on the one hand, and after CDN, access Faster too.

阿神

When I was studying database principles in school, the teacher repeatedly asked this question. I didn’t understand it at the time. Later, when I took JSP/Servlet as an elective, the teacher put everything he got into the database, and then I was confused. . .

伊谢尔伦

The path to store files in the database should not use absolute paths,

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template