Exemple #1
0
        public JsonResult GetActivityImg(int ID)
        {
            ACTIVITY_IMG act    = new ACTIVITY_IMG();
            var          result = act.Select(ID);

            return(Json(result));
        }
Exemple #2
0
        public ActionResult UploadImg()
        {
            ACTIVITY_IMG act    = new ACTIVITY_IMG();
            var          result = 0;
            int          ID     = Convert.ToInt32(Request["ID"]);
            var          mypath = "~/Upload/IMG/" + ID.ToString();
            var          path   = Server.MapPath(mypath);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i];
                if (file.ContentLength == 0)
                {
                    //Repeated upload file be skipped .
                    continue;
                }
                string savedFileName = Path.Combine(path, Path.GetFileName(file.FileName));
                file.SaveAs(savedFileName);
                string fileName = Path.GetFileName(file.FileName);
                result = act.Insert(ID, fileName);
            }
            if (result > 0)
            {
                TempData["message"] = "Upload success";
            }
            else
            {
                TempData["message"] = "Upload fail";
            }
            return(Redirect(Request.UrlReferrer.ToString()));
        }