I have the same issue
@using (Html.BeginForm(\"CreateRequest\", \"SupportRequest\", FormMethod.Post, new { id = \"f
Since you are creating the post of the data you will need to post the file data. see this post:
How can I upload files asynchronously?
I did the different way using form collection that can easily Upload files.Like u did add that line inside begin form in cshtml page.
public ActionResult Create([Bind(Include="Id,Name,Pic,ActiveStatus")] FormCollection form)
{
string Pic = "";
var file = Request.Files[0];
if (file.ContentLength > 0)
{
Pic = string.Format("~/Uploads/Category/{0}", file.FileName);
file.SaveAs(HttpContext.Server.MapPath(Pic));
}
ItemCategory obj = new ItemCategory
{
Name = form["Name"].ToString(),
Pic = file.FileName
};
db.ItemCategories.Add(obj);
db.SaveChanges();
return RedirectToAction("Index");
You need to use HttpPostedFileBase
in controller action parameters inorder to get the filedata that you have posted.
Please read this full article by Phil Haack