This article will show how to upload a file from client to server location in ASP.Net MVC application in 5 easy steps.
Create an ASP.Net MVC application.
File->New->Project->web->ASP.Net MVC Application
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.
- 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.