I am trying to submit a form containing a file upload using c# ASP MVC with Entity. My problem is that the file is always null.
The view :
@model Com.Work.With.Me.Models.ObjVM
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<form id="formObj" action="AddMe">
<input type="file" id="objPdfFile" name="Obj.PdfFile" />
</select>
<input type="text" id="objName" name="Obj.Name" />
</form>
The viewmodel :
public class ObjVM
{
public string Name{ get; set; }
public HttpPostedFileBase PdfFile{ get; set; }
public ObjVM()
{
}
}
The controller :
public ActionResult AddMe(ObjVM obj)
{
//her obj.Name is fine
//but obj.PdfFile is null
return View();
}
Any ideas?