How to delete uploaded files in MVC applications

Source: Internet
Author: User

How to delete uploaded files in ASP. net mvc applications.

During the upload, the real file is stored in a certain directory of the application. In the database table, only the basic information is stored. When deleting a transaction, note that there is no transaction to operate. The implementation method of Insus. NET is to first delete the files in the physical path and then delete the database records.

 

Open the database and write a stored procedure for deleting records:

 

Add a Delete method to FileLibraryEntity. cs:

 

Create a controller:


First, obtain the record information from the database, and then combine the file path to determine whether it exists and delete it if it exists. The last step is to delete database records.
Create View:

 
#1 mark to create a table header.
#2 Mark and reference the jQuery js library.
#3 mark, get all records and present them on tbody1.

Below is #4 mark the detailed code:

 

Demo:

 

Related Article

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.