Manage (update) uploaded files in the MVC application

Source: Internet
Author: User

The file upload function is implemented, and sometimes the upload operation fails, so that users can correct the file and develop the file upload function.

When uploading a file, if it is stored in a directory of the application, you need to understand the process during the update. First, delete the old file, update the information about the data table, and store the new file.

This article shows you the interaction between MVC and jQuery.

 

Create an updated stored procedure in the database:

 

Find and open FileLibraryEntity. cs and add a vlid update method:

 

In the ExerciseController. cs controller, create an update Action:

 

A mark to delete the old file.

Mark B to obtain information about the newly uploaded file.

Mark C to save the newly uploaded file.

D mark to update the database.

 

Next, modify the FileListMgr. cshtml view under Views/Exercise:

 

Mark 1, add a column, and let the user click to update a record.

Mark 2: Add a popup dialog box, which contains an upload markup.

Mark 3 and reference the js and Style Library in the popup dialog box.

Mark 4. Reference The js library and style document of uploadify.

 

In jQuery code, the following changes are made:

 

Mark 5 to dynamically generate the Update column button.

Mark 6 and point to Controller and Action.

Mark 7 and pass in the parameter. In order to let the Action know which record the user updates. (Key and key)

 

Demo:

 


MVC series exercises, the latest source program and database, can be downloaded from the following link.

Http://download.cnblogs.com/insus/MVC/InsusMVCSiteCS_Mar22_2014.rar

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.