public ActionResult EditDocumentUpload(RecruitmentViewModel rvm, HttpPostedFileBase[] FILEPhoto) { string Name = string.Empty; string strImageLink = string.Empty; string ext = string.Empty; int rid = default(int); rid = rvm.RecruitmentId; RecruitmentService recruitmentService = new RecruitmentService(); //Upload Files foreach (HttpPostedFileBase varfile in FILEPhoto) { if (varfile != null && varfile.ContentLength > 0) { ext = Path.GetExtension(varfile.FileName); //Name = Guid.NewGuid() + ext; Name = varfile.FileName; strImageLink = strImageLink + Name + ","; var newFileName = Path.Combine(Server.MapPath("~" + ConfigurationManager.AppSettings["RecruitDocument"]), Name); varfile.SaveAs(newFileName); } } //Insert data into RecruitmentDocuments foreach (HttpPostedFileBase varfile in FILEPhoto) { if (varfile != null && varfile.ContentLength > 0) { RecruitmentDocument Objrd = new RecruitmentDocument() { RecruitmentId = rid, FileServerPath = ConfigurationManager.AppSettings["RecruitDocument"], RecruitmentDocumentName = varfile.FileName, IsActive = true, IsDeleted = false, CreatedUserId = User.Identity.GetUserId(), CreatedDate = DateTime.Now }; recruitmentService.SetRecruitmentDocument(Objrd); } } return(RedirectToAction("Edit", "Recruitment", new { id = rid })); }