Hardik Dhankecha
How to set path of Image folder in MVC?
By Hardik Dhankecha in .NET on Apr 12 2018
  • Mohit Kala
    Sep, 2018 3

    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;}

    • 0
  • Shivam Shukla
    Jun, 2018 27

    You just have to use the server path:Server.MapPath("~/Images/")

    • 0
  • Hardik Dhankecha
    Apr, 2018 12

    [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 in view

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS