.ashx接收APPCAN发送过来的图片数据流,保存为图片
2016-04-27 16:38
369 查看
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; using System.Drawing; using System.Web.SessionState; namespace BlankOrder { /// <summary> /// ImageHandler 的摘要说明 /// </summary> public class ImageHandler : IHttpHandler, IReadOnlySessionState { public void ProcessRequest(HttpContext context) { var httpRequest = System.Web.HttpContext.Current.Request; HttpFileCollection uploadFiles = httpRequest.Files; try { //int vals = context.Request.TotalBytes; //byte[] buffer = context.Request.BinaryRead(vals); string imgname = DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg"; string filePath = "/img/userupphoto/" + imgname; if (context.Request.Files.Count > 0) { int i; for (i = 0; i < uploadFiles.Count; i++) { HttpPostedFile postedFile = uploadFiles[i]; Image img = new Bitmap(postedFile.InputStream); img.Save(context.Server.MapPath(filePath)); img.Dispose(); } } } catch (Exception e) { } } public bool IsReusable { get { return false; } } } }
相关文章推荐
- iOS如何获取手机的Mac地址
- 模拟UA实现访问只能在微信上打开的网页
- iOS极光推送之自定义消息
- android inflater 用法
- 关于Android的问号?和@符号的用法
- 【Unity】基于MVC模式的双肩包系统 UGUI实现
- iOS更新学习(2)
- ListView列表控件的使用
- iOS 引导页的制作和使用
- android电池管理系统
- Android Studio 卡顿问题解决方案
- Android IOS WebRTC 音视频开发总结(七十)-- 移动端音视频技术优化的七个方向
- APP测试功能点总结
- 移动端使用js出轻量级吐司提示
- MeasureSpec介绍及使用
- 不常用的 IO 流对象:ObjectInputStream/ObjectOutputStream
- Android消息机制
- Unity3d开发(十二)使用Menu.SetCheck更改菜单勾选状态
- iOS开发之.pch文件初识
- Android 插件换肤原理解析