I'm just trying to create a form where I can enter a name and upload a file. Here's the view model:
public class EmployeeViewModel { [ScaffoldColumn(false)] public int EmployeeId { get; set; } public string Name { get; set; } public HttpPostedFileBase Resume { get; set; } } My view:
@using (Html.BeginForm("Create", "Employees", FormMethod.Post)) { @Html.TextBoxFor(model => model.Name) @Html.TextBoxFor(model => model.Resume, new { type = "file" }) <p> <input type="submit" value="Save" /> </p> @Html.ValidationSummary() } And my controller method:
[HttpPost] public ActionResult Create(EmployeeViewModel viewModel) { // code here... } The problem is that when I post to the controller method, the Resume property is null. The Name property gets passed just fine, but not the HttpPostedFileBase.
Am I doing something wrong here?