I want to pass image as well as some data from view to controller on submit button click.
Bellow is my code
My View
@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"/>
}
My controller action
[HttpPost]
public ActionResult AccountPhotoPost(HttpPostedFileBase file, long accountId)
{
}
Here problem is that as it is FormMethod.Post , data is not passed from view to controller & if I remove this then data is passed but image is not passed.
How can I send both together ?
Try this
in Controller