<body>
@using (Html.BeginForm("Index", "Default1", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="name" value=" " /><br />
<input type="submit" name="name" value="上传" />
}
</body>
// GET: /Default1/
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
//if (file.ContentLength > 0)
//{
HttpPostedFileBase fileObj = Request.Files[0];
fileObj.SaveAs(Server.MapPath("UploadFile/") + "1234.txt");
//}
return View("Index");
}