0
我正在处理多个文件,我正在使用HttpPostedFileBase
。文件HttpPostedFileBase上传文章NULL在部分视图上MVC
提交表格时,file
属性为null
。
型号
public partial class Driver
{
public int DriverId { get; set; }
public string DriverFirstName { get; set; }
....
public List<DriverImages> DriverImages { get; set; }
}
public class DriverImages
{
public int DriverImageID { get; set; }
public string ImagePath { get; set; }
public string Description { get; set; }
public HttpPostedFileBase file { get; set; }
}
局部视图
@model DataModel.DriverImages
...
@using (Design.Common.HtmlPrefixScopeExtensions.BeginCollectionItem(this.Html, "DriverImages"))
{
<table>
<tr>
<td>
@Html.TextBoxFor(m => Model.Description)
</td>
<td>
<input type="file" name="file" />
</td>
</tr>
</table>
}
控制器
[httppost]
public ActionResult Create(Driver ObjDriverModel, HttpPostedFileBase[] files)
{
// ObjDriverModel.DriverImages.file // always null
}
伟大的帮助...它现在发布我的文件..谢谢很多 –