62,074
社区成员
发帖
与我相关
我的任务
分享
@using (Html.BeginForm("UpAFile", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input id="file" type="file" />
<input type="submit" class="btn btn-default" value="提交" />
}
[HttpPost]
public ActionResult UpAFile(HttpPostedFileBase file)
{
if (file == null || file.ContentLength == 0)
return View();
try
{
string fileFolder = "savedir\\";
var path = Path.Combine(fileFolder, file.FileName);
file.SaveAs(path);
return View();
}
catch (Exception ex)
{
//return 0;
}
return View();
}