@using (Html.BeginForm("UploadVideos", "Videos", FormMethod.Post, new { enctype = "multipart/form-data", @data_ajax = "false" })) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <input type="file" value="file" id="fileCntrl" name="uploadFile" accept="video/*" data-val="true" data-val-required="File is required" /> <input type="submit" value="Upload" /> }
public ActionResult UploadVideos() { return View(); } [HttpPost] public ActionResult UploadVideos(HttpPostedFileBase fileCntrl) { if (fileCntrl != null && fileCntrl.ContentLength > 0) { var filename = Path.GetFileName(fileCntrl.FileName); var path = Path.Combine(Server.MapPath("~/Images"), filename); fileCntrl.SaveAs(path); } return View(); }
name
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)