I keep on getting null with HttpPosterFileBase when I try uploading a file:
I have this code in my view:
@using (Html.BeginForm("Import", "Control", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="fileUpload"/>
<input type="submit" value="Import" id="btnImport" class="button" />
}
And this code with my controller:
[HttpPost]
public ActionResult Import()
{
HttpPostedFileBase file = Request.Files[fileUpload];
Other codes...
}
I also tried this in my controller:
[HttpPost]
public ActionResult Import(HttpPostedFileBase fileUpload)
{
Other codes...
}
After pressing the submit button the "file" got a value of null.