public string DeleteImg(string id)
        {
            UploadImage img  = new FileUploadBll().GetUploadImageByUploadImageId(id);
            string      path = Server.MapPath("../" + img.PictureUrl);

            FileHelper.DeleteFile(path);
            return(new FileUploadBll().DeleteUpLoadImageInfo(id) ? "success" : "error");
        }
        public JsonResult GetUpLoadImg()
        {
            string search           = Request.Params["search"];
            int    offset           = int.Parse(Request.Params["offset"]);
            int    pagesize         = int.Parse(Request.Params["pageSize"]);
            int    total            = 0;
            IList <UploadImage> img = new FileUploadBll().GetImages(offset, pagesize, search, out total);
            var grid = new { rows = img, total = total };

            return(Json(grid));
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string msg = "";

            try
            {
                bool           flag           = false;
                HttpPostedFile upload         = HttpContext.Current.Request.Files["inputfile"];
                string         uploadFileName = upload.FileName;
                if (uploadFileName.Contains("\\"))      //如果获取的是路径(浏览器设置的不同),则截取文件名
                {
                    uploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
                }
                string   saveuploadPath = System.Web.HttpContext.Current.Server.MapPath("~/Docs/" + uploadFileName);//文件要上传到服务器的路径
                FileInfo uploadFile     = new FileInfo(saveuploadPath);
                if (uploadFile.Exists)
                {
                    uploadFile.Delete();
                }
                upload.SaveAs(saveuploadPath);//相当于从本地上把要上传的文件下载到服务器
                Classes cl = new Classes();
                cl.Cname = uploadFileName;
                cl.Cpath = "../Docs/" + uploadFileName;
                FileUploadBll fb = new FileUploadBll();
                flag = fb.FileUpload(cl);
                if (flag == true)
                {
                    //context.Session["username"] = um.Uname;//保存UserNum
                    msg = "1";
                }
                else
                {
                    msg = "0";
                }
            }
            catch
            {
                msg = "88";
            }
            context.Response.Write(msg);
        }