Sunday, 11 May 2014

upload image in mvc

No comments
in controller


[HttpPost]
        public ActionResult Img(HttpPostedFileBase file)
        {
            if (!Directory.Exists(Server.MapPath("~/image")))
            {
                Directory.CreateDirectory(Server.MapPath("image"));
            }
            string name = file.FileName;
            string path = Path.Combine(Server.MapPath("~/image"),name);
            file.SaveAs(path);
            return RedirectToAction("Exp");
        }