Hi All,
I am getting HttpPostedFileBase null always. I have tried most of the solutions found in the net. But did not work. Could you please help me? Below is my code.
@using (Html.BeginForm("FileUpload", "BureauReporting", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="uploadFile" id="uploadFile" />
<input type="submit" />
}
public ActionResult FileUpload(HttpPostedFileBase uploadFile)
{
try
{
// TODO: Add insert logic here
if (ModelState.IsValid)
{
if (uploadFile.ContentLength > 0)
{
var fileName = Path.GetFileName(uploadFile.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
uploadFile.SaveAs(path);
}
}
Thanks,
Lijo