View
1. name attribute should be same as parameter in controller
<div class="form-row" id="attach"> <div class="col-md-4 hidden" id="invoice"> <div class="form-group"> <label class="control-label col-md-2">Invoice</label> <div class="col-md-10"> <input type="file" id="Invoice" name="Invoice" class="form-control" /> </div> </div> </div> </div> |
Controller
[HttpPost] public ActionResult FileUpload(Registration model, HttpPostedFileBase Invoice) { if (Invoice != null) { var savingpath = "~/UploadedFiles/ExciseFiles/" + DateTime.Now.Ticks.ToString().Substring(12) + "_" + Invoice.FileName; var filePath = Server.MapPath(savingpath); model.Invoice = savingpath; Invoice.SaveAs(filePath); } } |
0 Comments