I am sending a form to my Controller by passing a HttpPostedFileBase
as a parameter. The problem is that it always comes empty.
HTML :
<form action="@Url.Action("Import","Importacao")" method="post" class="form-horizontal">
<div class="form-group ">
<label for="fupload" id="label-fupload" class="control-label label-bordered">Clique aqui para escolher um arquivo</label>
<input type="file" id="fupload" name="fupload" class="fupload form-control border-form" onchange='getFileName()' />
</div>
<div class="form-group">
<label for="mes_referencia" class="control-label">Mês</label>
<input type="text" id="mes_referencia" name="mes_referencia" class="mes_referencia form-control" placeholder="mm/yyyy" />
</div>
<input type="submit" class="btn btn-success" id="submit" value="Enviar" style="margin-left: 200px;" />
Controller :
[HttpPost]
public ActionResult Import(HttpPostedFileBase fupload){
if (fupload != null && fupload.ContentLength > 0) {
dataset = Importador.UploadAndShow(fupload);
}
return View(dataset.Tables[0]);
}
I've already used the name
parameter equal to the Method parameter, as well as id
and class
.
Thank you!