Hi I have a dialog popup contains update form and an upload input I created update action and I added some upload codes the problem is the input file is always null in the form
Controller
[HttpPost]
public ActionResult Setting(user user, HttpPostedFileBase file)
{
View
@model Magellane.Models.user
@using (Html.BeginForm("Setting", "Account", FormMethod.Post, new { role = "form", id = "profileForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<input type="hidden" name="user_id" value="@Session["user_id"]">
<div class="form-group">
<label for="pass1" class="col-sm-2 control-label">Nom decole</label>
<div class="col-sm-10">
<input class="form-control-modal required" id="company" type="text" value="@Model.company" name="company" minlength=5>
<span class="field-validation-error" data-valmsg-for="company" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<label for="pass1" class="col-sm-2 control-label">Logo</label>
<input type="file" class="margin-none" name="logo" id="file" onchange="readURL(this);" />
</div>
$.ajax({
url: '/Account/setting',
type: 'POST',
data: $('form').serialize(),
dataType: 'json',
async: false,
success: function (xhr, status, error) {
bootbox.alert(xhr.message);
},
error: function (xhr, ajaxOptions, thrownError) {
bootbox.alert(thrownError);
}
});
Is there any solution?