Пример #1
0
        public JsonResult UploadFile(HttpPostedFileBase uploadfilename, string touid)
        {
            KNet.AAMS.Web.Security.ApplicationIdentity identity =
                this.User.Identity as KNet.AAMS.Web.Security.ApplicationIdentity;
            var upload = FileUploadHelper.Upload(uploadfilename, Server.MapPath("~/upload/file"), identity.Id, touid,
                                                 false);

            var result = Json(upload, JsonRequestBehavior.DenyGet);

            return(result);
        }
Пример #2
0
        public JsonResult UploadImg(HttpPostedFileBase uploadimgname, string touid)
        {
            string strPostfix = uploadimgname.FileName.Substring(uploadimgname.FileName.LastIndexOf(".") + 1);

            if (strPostfix.ToLower() != "gif" && strPostfix.ToLower() != "jpg" && strPostfix.ToLower() != "pic" &&
                strPostfix.ToLower() != "bmp" && strPostfix.ToLower() != "jpeg" && strPostfix.ToLower() != "png")
            {
                return(Json(JsonResultHelper.CreateJson(null, false, "请上传图片格式" + "(bmp;jpg;jpeg;png;tif;pic;)"),
                            JsonRequestBehavior.DenyGet));
            }

            KNet.AAMS.Web.Security.ApplicationIdentity identity =
                this.User.Identity as KNet.AAMS.Web.Security.ApplicationIdentity;
            var upload = FileUploadHelper.Upload(uploadimgname, Server.MapPath("~/upload/img"), identity.Id, touid, true);


            /*作者原来这样写 可能是有些浏览器前端不能够识别json吧*/
            //var result = Json(upload, "text/html", JsonRequestBehavior.DenyGet);
            var result = Json(upload, JsonRequestBehavior.DenyGet);

            return(result);
        }