How do I store uploaded files in Web applications? Folder: Database (1)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.