Reputation: 1007
I have a form that is supposed to take the user's credentials and his resume. PDF/DOC
I already have a database where I plan to store the server path to the uploaded file as a string
I generated a strongly typed view that takes in the file via
<%: Html.EditorFor(model => model.file, new { type = "file" })%>
I have created a HttpPostedFileBase object in the model. And the model.file is supposed to store HttpPostedFileBase file object.
But in the controller when I try to get the model.file object, I get null as its value.
What am I doing wrong. Why is model binding not binding file upload ?
Upvotes: 0
Views: 198
Reputation: 15866
add enctype="multipart/form-data"
to form options
@using (Html.BeginForm("Action",
"Controller",
FormMethod.Post,
new
{
id = "form", enctype="multipart/form-data"
}))
{
}
Upvotes: 4