public ActionResult AlbamPhotos(AlbamPhoto add, HttpPostedFileBase File) { album.Add_Albam_Photo(add, File); //Message TempData["msg"] = "<script>alert('Upload Albam Photos Successfully');</script>"; //Current Url Redirect return(Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri)); // return View(); }
//add Album Photo public bool Add_Albam_Photo(AlbamPhoto add, HttpPostedFileBase File) { string filename = Path.GetFileNameWithoutExtension(File.FileName); string extension = Path.GetExtension(File.FileName); filename = filename + DateTime.Now.ToString("yymmssfff") + extension; add.ImagePath = "~/Content/Image/AlbamPhoto/" + filename; filename = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Image/AlbamPhoto/"), filename); File.SaveAs(filename); Db.Set <AlbamPhoto>().Add(add); Db.SaveChanges(); return(true); }