I already tried all solutions that I found on StackOverflow but they are not working for me. I also tried Tetsuya Yamamoto solution but still its always returning null
when I am using it with model.
Update
When I am inspecting it then my file type input hold data but in inspected element its value is ""
In both ways my posted file is like this
@using (Html.BeginForm("AddLocation", "MasterData", FormMethod.Post, new { encytype = "multipart/form-data"}))
{
<div class="file-upload">
<input type="file" name="postedFile" />
</div>
//passing model value when using it
}
without model working perfact
public ActionResult AddLocation(HttpPostedFileBase file)
{
try
{
if (file != null) //Working Perfact
{
}
return View(model);
}
catch (Exception ex)
{
return View(model);
throw;
}
}
with model always rerunning null
public ActionResult AddLocation(LocationModel model, HttpPostedFileBase file)
{
try
{
if (ModelState.IsValid)
{
if (file != null) //Always return null when passing with model
{
}
}
return View(model);
}
catch (Exception ex)
{
return View(model);
throw;
}
}