[HttpPost] public ActionResult Create(AdulLiteracyTeachers adulliteracyteachers, HttpPostedFileBase[] files) { foreach (HttpPostedFileBase file in files) { string path = System.IO.Path.Combine(Server.MapPath("~/App_Data"), System.IO.Path.GetFileName(file.FileName)); file.SaveAs(path); } if (ModelState.IsValid) { db.AdulLiteracyTeachers.Add(adulliteracyteachers); db.SaveChanges(); return RedirectToAction("Index"); }
using (Html.BeginForm("Create", "AdultLiteracyTeachers", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.ValidationSummary(true) <label for="file">Upload Image:</label> <input type="file" name="files" value="" multiple="multiple"/> <input name="Upload" type="submit" value="Create" />
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)