Web Programming

Only members of this group can post notes and use other group resources. Join now to get access to all group resources!
Log in or register to join this group

.NET File Upload ASP.NET MVC  Viewed 14519 time(s), 2 post(s)., 1/11/2014 9:00:34 PM - by James

James
James 1/11/2014 9:00:34 PM

How to upload a file in MVC?

This content has not been rated yet. 
216 Reputation 15 Total posts
1
Jude
Jude 1/26/2014 9:04:13 PM

In MVC, you don't use Server controller.

Try this code to upload a file in MVC

1.public ActionResult Index(HttpPostedFileBase file)
2.    {
3.      
4.            var fileName = Path.GetFileName(file.FileName);
5.             
6.            var uploadpath = Path.Combine(Server.MapPath("Path where you want to store the file"), fileName);
7.            file.SaveAs(uploadpath);
8.    }

This content has not been rated yet. 
106 Reputation 16 Total posts
2