public static string ProfileUpload(HttpPostedFileBase proiflePic){string fileName = Path.GetFileNameWithoutExtension(proiflePic.FileName);string extension = Path.GetExtension(proiflePic.FileName);fileName = fileName + DateTime.Now.ToString("yymmssff") + extension;proiflePic.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/Image/ProfileUpload/"), fileName));return fileName;}
You just have to use the server path:Server.MapPath("~/Images/")
[HttpPost]public ActionResult Register(Employee employee, HttpPostedFileBase file){string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName));file.SaveAs(path);Employee _emplyee = new Employee();_emplyee.Name = employee.Name;_emplyee.Username = employee.Username;_emplyee.EmailId = "~/Images/" + file.FileName;_emplyee.Password = employee.Password;_emplyee.Gender = "Male";_emplyee.FkCityId = employee.FkCityId;_emplyee.FkCountryId = employee.FkCountryId;_emplyee.FkStateId = employee.FkStateId;TestEntities db = new TestEntities();db.Employees.Add(_emplyee);db.SaveChanges();return RedirectToAction("Register", "Home");}also set