CSDN广告是越来越多了,所有博客笔记不再更新,新网址
DotNet笔记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>
<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>
处理程序:
- 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();
- }
- }