Asp.net MVC 实现图片上传剪切(6)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:20 点击:

 13                 Image image = Image.FromStream(Filedata.InputStream);
 14                 string ipath = Path.Combine("Images", Path.GetFileName(Filedata.FileName));
 15                 string spath = Path.Combine(HttpContext.Server.MapPath("~"), ipath);
 16                 image.Save(spath);
 17
 18                 return Json(new { id = "0", mess = string.Format("{0}{1}/{2}", BaseUrl, "Images", Filedata.FileName), iw = image.Width, ih = image.Height });
 19             }
 20             catch (Exception ex)
 21             {
 22                 return Json(new { id = "1", mess = ex.Message });
 23             }
 24         }
 25
 26         public void tryCrop(string img, int x, int y, int w, int h)
 27         {
 28             Image image = Image.FromFile(Path.Combine(HttpContext.Server.MapPath("~"), "Images", img));
 29             Crop(image, w, h, x, y).Save(Path.Combine(HttpContext.Server.MapPath("~"), "Images", "v" + img));
 30
 31             Response.Redirect(string.Format("{0}{1}/{2}", BaseUrl, "Images", "v" + img));
 32         }
 33
 34         [NonAction]
 35         public string BaseUrl
 36         {
 37             get
 38             {
 39                return Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + '/';
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • 浅析.NET下XML数据访问新机制
  • asp.net 面试+笔试题目第1/2页
  • C# 邮件地址是否合法的验证
  • asp.net 设置GridView的选中行的实现代码
  • C#高级编程:数据库连接[1]
  • 经典C++程序1
  • IIS 自动回收导致后台定时器失效的问题解决
  • ASP.NET GridView列表代码示例
  • Asp.net MVC源码分析--Action Filter的链式调用
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1