How do I store uploaded files in Web applications? Folder: Database (1)
Author: chinamao mailbox: chinamao@gmail.com reprint please indicate the source of related articles
There is a debate about whether files uploaded in web applications are stored in folders or databases. Many of the current practices are based on the actual situation, this article describes one way to combine these two methods.
There are two main methods to upload and download files:
1. Save the file in a folder;
2. Save the file in the database.
The two methods have their own advantages and disadvantages:
For example, if a file is saved in a folder on the server, the speed of file uploading and downloading is advantageous. However, this method is not convenient for file management. For example, if the folder is moved to another location or the server's hard disk is full, you have to update the file link by placing the file elsewhere. Of course, this is not conducive to the backup of files and materials.
However, when files are stored in the database, the speed of reading and writing of large-capacity databases is weak. However, in this way, all files are stored in the database, it is very convenient for file searching, management, and backup.
The above two methods will be used in the project. Put the file in a specific folder on the server and upload it to the database. When you read a file, if the file exists in the folder, you can directly read it, instead of accessing the database. If this file is not in the folder, read it from the database and put it in this folder. In this way, when the user accesses the same file for the second time, the user does not need to access the database, and read from the folder directly.
This method combines the advantages of folder storage and database storage. It not only provides access efficiency through folders, but also facilitates management of database storage methods.
Our specific practice is to apply the jspsmartupload component and use the SQL stored procedure.
The specific practice is to be continued.