HTML:
<body> <div> <form action="/home/uploadimg" method="post" enctype="multipart/form-data"> <input type="file" name="file1" /> <input type="submit" value="submit" /> </form> </div> </body>
Controller:
public class HomeController : Controller { public ActionResult Index() { return View(); } [HttpPost] public ActionResult UploadImg() { if (Request.Files.Count > 0) { HttpPostedFileBase f =Request.Files["file1"]; f.SaveAs(@"D:\" + f.FileName); } return View(); } }