WEB application's storage mode of upload files? Folder: Database (1)
Author: chinamao-mail:
CHINAMAO@gmail.com Reprinted please indicate the source
related articles
About the files uploaded in web applications are placed under the folder or in the database, there are some debates, and now, many practices are based on the actual situation. This paper is to introduce one way to combine these two methods.
There are two ways to upload and download implementation:
1. Save the file in the folder;
2. Save the file in the database.
These two methods have advantages and disadvantages:
For example, files are saved in the server's folder, there is an advantage in the speed, upload, downloads just through the link read files, but this method is inconvenient for file management. For example, the folder transfer position, or the server hard disk is full, put the files elsewhere to update the file link. Of course, it is also not conducive to the backup of the file information.
The file is placed in the database because the read and write of the large-capacity database is involved, and the speed is a bit weak, but this method, the file is all in the database, which is very convenient for file search, management, and backup.
We will adopt the above two methods in the project. That is, put the file in a specific folder in the server, then upload it to the database, so when the user reads a file, if there is this file in the folder, read it directly without accessing the database. If there is no file in the folder, you read from the database, then put it in this folder so that when the user has access the same file for the second time, you do not need to access the database, and read directly from the folder.
This method combines the advantages of both the folder storage method and the data inventory. Not only has the access efficiency of the folder, but also the advantages of facilitating management of data inventories.
Our specific practice is to apply JSPSMARTUPLOAD components and use SQL stored procedures to be implemented.
Details of practice.