public ActionResult PatientRegistration(PatientViewModel pvm, HttpPostedFileBase Prescribtion) { // Verify that the user selected a file if (Prescribtion != null && Prescribtion.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(Prescribtion.FileName); // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/Prescriptions"), fileName); Prescribtion.SaveAs(path); pvm.Prescribtion = "Prescriptions/" + fileName; } else { pvm.Prescribtion = ""; } int res = pvm.Save(); if (res != 0) { pvm.Msg = "Patient Details Saved Successfully"; } else { pvm.Msg = "Patient Details Cannot be saved"; } pvm.GetAllPatientDetailsByUserId(); // redirect back to the index action to show the form once again return(View("PatientRegistration", pvm)); }