【发布时间】:2012-11-08 10:07:01
【问题描述】:
我想在单击提交按钮时将图像以及一些数据从视图传递到控制器。 下面是我的代码
我的观点
@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 ,数据不会从视图传递到控制器,如果我删除它,那么数据会传递但图像不会传递。
如何同时发送?
【问题讨论】:
标签: asp.net-mvc-3 razor