File Upload in ASP.Net MVC application
Objective:
This article will show how to upload a file from client to server location in ASP.Net MVC application in 5 easy steps.
Step 1:
Create an ASP.Net MVC application.
File->New->Project->web->ASP.Net MVC Application
Step 2:
Creating controller
a. Right click on Controller folder and add a new controller.
FileUpload is name of the controller here. Don't check the checkbox.
Description of HttpPostedFileBase class
For uploading the file in specified path at serverHttpPostedFileBase class from System.Web namespace would be used.
HttpPostedFileBase class
- This contains 4 properties
- This contains one virtual method.
- FileName property will be used to fetch the file name of the file.
- SaveAs method will be used to save the file at server location.
Comments