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('/') + '/';
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>