【发布时间】:2014-11-27 07:12:49
【问题描述】:
我无法检索控制器中的值,它返回 null。请帮助我找出我做错了什么。
下面是我的代码
索引.aspx
<form id="form1" method="post" action="/Sample/Index" enctype="multipart/form-data">
<div>
<input type="text" id="PcId" value=<%=Model.PcId %> /></div>
<input type="file" value="Browse" id="file"/>
<input type="submit" id="submit" value="Save"/></div>
</form>
在我的控制器中
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
string PcId = Request.Form["PcId"];
List<string> fileConfigData = new List<string>();
if (file != null && file.ContentLength > 0)
{
string FolderPath = mPath.GetFolderPath();
var fileName = Path.GetFileName(file.FileName);
string filePath = Server.MapPath(FolderPath + PcId) + "\\" + fileName;
file.SaveAs(filePath);
}
return view();
}
【问题讨论】:
-
你关闭了
<div>2 次。