When I try to upload a file, it is always null but the username passes over.
<div class="container">
@using(Html.BeginForm("Upload", "ADImage", FormMethod.Post, new { enctype = "mulipart/form-data" }))
{
<fieldset>
<legend>AD Image Upload</legend>
<label>AD Username</label>
<div class="input-control text" data-role="input-control">
<input type="text" name="username" placeholder="Username" />
<button class="btn-clear" tabindex="-1" type="button"></button>
</div>
<label>Choose File</label>
<div class="input-control file info-state" data-role="input-control">
<input type="file" name="file" tabindex="-1" style="z-index: 0;" />
<input type="text" id="input_file_wrapper" readonly style="z-index: 1; cursor: default;" />
<button class="btn-file" type="button"></button>
</div>
<button type="submit" value="Submit">Submit</button>
</fieldset>
}
</div>
Controller
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file, string username)
{
if (string.IsNullOrWhiteSpace(username))
{
ViewBag.IsUserValid = false;
}
else if (file == null | file.ContentLength.Equals(0))
{
ViewBag.IsFileValid = false;
}
else
{
byte[] fileBytes = ReadFile(file.InputStream);
}
return RedirectToAction("Index");
}