@using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" })) { <div class="choose-file">Choose a file to upload:</div> <div class="input-group"> <span class="input-group-btn"> <span class="btn btn-primary btn-file" style="padding:4px 12px; background:#25374a; height:30px;"> Browse… <input type="File" id="FileUpload" name="FileUpload" class="button5" /> </span> </span> <input type="text" readonly="" style="height:30px; box-shadow:none;" class="form-control"> </div> }
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(HttpPostedFileBase FileUpload) { if (FileUpload.ContentLength > 0) { string fileName = Path.GetFileName(FileUpload.FileName); string path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); try { FileUpload.SaveAs(path); dt = ProcessCSV(path); //Process the DataTable and capture the results to our SQL Bulk copy ViewBag.Message = ProcessBulkCopy(dt); Session["rowcnt"] = dt.Rows.Count; } catch (Exception ex) { ViewBag.Message = ex.Message; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)