我希望将图像以及视图中的一些数据传递给控制器。 贝娄是我的代码将图像和数据从视图传递到控制器
我查看
@using (Html.BeginForm("AccountPhotoPost", "Post", FormMethod.Post, new {enctype = "multipart/form-data", accountId = Model.accountId }))
{
<text>Post Photo : </text> <input type="file" name="file" id="file" />
<input type="submit" value="Post Photo" id="saveButton"/>
}
我的控制器动作
[HttpPost]
public ActionResult AccountPhotoPost(HttpPostedFileBase file, long accountId)
{
}
这里的问题是,因为它是FormMethod.Post,数据不会从视图中传递,如果到控制器&我删除它然后数据通过但图像不通过。
如何将两者一起发送?