//[ValidateAntiForgeryToken] public ActionResult SaveHead(int x, int y, int width, int height, string headFileName) { if (!WebSecurity.IsAuthenticated) { return(this.Content(ModifiyScript(new BaseState(-1, "用户还未登录")))); } var model = new UploadImageModel(); model.headFileName = this.Request["headFileName"]; model.x = Convert.ToInt32(this.Request["x"]); model.y = Convert.ToInt32(this.Request["y"]); model.width = Convert.ToInt32(this.Request["width"]); model.height = Convert.ToInt32(this.Request["height"]); var filepath = Path.Combine(this.Server.MapPath("~/avatarImage/temp"), model.headFileName); var fileExt = Path.GetExtension(filepath); var key = ""; using (var cutedstream = this.CutAvatar(filepath, model.x, model.y, model.width, model.height, 75L, 180) ) { key = this._imagefile.SaveImageFile(cutedstream, model.headFileName, new[] { new ImagesSize { Height = 180, Width = 180 }, new ImagesSize { Height = 75, Width = 75 }, new ImagesSize { Height = 50, Width = 50 }, new ImagesSize { Height = 25, Width = 25 }, }); cutedstream.Close(); } this._userService.UpdateUserAvatar(WebSecurity.CurrentUserId, key); //Dev.Comm.FileUtil.DeleteFile(filepath); var state = new BaseState(0, key); var script = ModifiyScript(state); return(this.Content(script)); return(this.Json(new BaseState(0, key), JsonRequestBehavior.AllowGet)); }
//[ValidateAntiForgeryToken] public ActionResult SaveHead(int x, int y, int width, int height, string headFileName) { if (!WebSecurity.IsAuthenticated) { return this.Content(ModifiyScript(new BaseState(-1, "用户还未登录"))); } var model = new UploadImageModel(); model.headFileName = this.Request["headFileName"]; model.x = Convert.ToInt32(this.Request["x"]); model.y = Convert.ToInt32(this.Request["y"]); model.width = Convert.ToInt32(this.Request["width"]); model.height = Convert.ToInt32(this.Request["height"]); var filepath = Path.Combine(this.Server.MapPath("~/avatarImage/temp"), model.headFileName); var fileExt = Path.GetExtension(filepath); var key = ""; using (var cutedstream = this.CutAvatar(filepath, model.x, model.y, model.width, model.height, 75L, 180) ) { key = this._imagefile.SaveImageFile(cutedstream, model.headFileName, new[] { new ImagesSize { Height = 180, Width = 180 }, new ImagesSize { Height = 75, Width = 75 }, new ImagesSize { Height = 50, Width = 50 }, new ImagesSize { Height = 25, Width = 25 }, }); cutedstream.Close(); } this._userService.UpdateUserAvatar(WebSecurity.CurrentUserId, key); //Dev.Comm.FileUtil.DeleteFile(filepath); var state = new BaseState(0, key); var script = ModifiyScript(state); return this.Content(script); return this.Json(new BaseState(0, key), JsonRequestBehavior.AllowGet); }