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