Manage (update) uploaded files in an MVC application

Source: Internet
Author: User

To implement the upload file function, sometimes upload will also operate error, can let the user have the opportunity to correct, the development of uploading files can have updated features.

When the file is uploaded, if it is stored in a directory of the application, you need to know some processes when updating, first delete old files, update data table related information, store new files.

This article gives you an idea of how MVC interacts with jquery.

In the database, create a new stored procedure that is updated:

Locate and open FileLibraryEntity.cs, and add a vlid Update method:

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

A tag to delete the old file.

b tag to get the new upload file information.

C tag, save the new upload file.

D tag to update the database.

Next, we modify the views/exercise/filelistmgr.cshtml view:

Tag 1, add a column that lets the user click to update a record.

Tag 2, add a popup dialog box, inside is an upload markup.

Tag 3, referencing the JS and style Library of the popup dialog box.

Tag 4, referencing Uploadify's JS library and style document.

In the jquery code, there are several changes in the following positions:

Tag 5, dynamically produces the button that updates the column.

Mark 6, point to Controller,action.

Tag 7, passing in parameters, in order for the action to know which record the user is updating. (Focus and key)

Demonstrate:

2014-03-22 14:30 Add the following:
MVC series Exercises, the latest source programs and databases, can be downloaded from the link below.

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.