Hello Friends, In this tutorial, I am going to create an example for how to Upload File in ASP.NET MVC.

Introduction:

Upload File is an important task for every application. In this tutorial, I am going to create an example for Uploading File. The posted file is available as HTTPPostedFileBase.

Upload File

Upload File in ASP.NET MVC.

Step 1- Open visual studio and create an MVC4 application called  UploadFileDemo,

Upload File

Step 2- Choose an empty template and Click OK. An empty solution will be completed.

Step 3- Right Click on the Controllers folder and Create a Controller called HomeController. A Controller with the following code will be created.

Step 4- Right Click on the Index action method and Add a View called Index.

Step 5- Write the following code into Index.cshtml.

Step 6- Right Click on the Solution Explorer and create a folder called Scripts.

Step 7- Add the following Scripts in the Scripts folder that we have created in Step 6.

  • jquery-1.7.1.min.js.
  • jquery.validate.min.js.
  • jquery.validate.unobtrusive.min.js.

Step 8- Right Click on the Scripts folder and Create a JavaScript file called App.Js. Write the following code in App.js.

Step 9- Now the complete code for the View would be.

Step 10-  Right Click on the Solution Explorer and create a folder Content.

Step 11- Goto HomeController and write the following method in HomeController.

Run the application and look at the output screen.

Upload File

You can download the complete Source Code for the application from here.

Conclusion:

Hope you understand this tutorial about Uploading File in ASP.NET MVC. I will appreciate your feedback, comments and suggestions.

View More:

Thank You.

One Thought to “How to upload file in in ASP.NET MVC”

  1. I have been browsing online more than 3 hours
    today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my opinion, if all web owners and bloggers made
    good content as you did, the net will be much more useful than ever before.

     

Leave a Comment