文件下载(尚有不明,进行学习中)

view页面

<form action="/Main/UploadFile" method="post" enctype="multipart/form-data">
<input type="file" name="file" /><br />
<input type="submit" value="提交" />
</form>

Controller

1  public ActionResult UploadFile(HttpPostedFileBase file)
2         {
3             var fileName = file.FileName;
4             var filePath = Server.MapPath(string.Format("~/{0}", "File"));
5             file.SaveAs(Path.Combine(filePath, fileName));
6             return View();
7         }
View Code

猜你喜欢

转载自www.cnblogs.com/chenze-Index/p/9234521.html