二进图片保存到本地或服务器
来源:互联网 发布:网络爬虫爬取什么赚钱 编辑:程序博客网 时间:2024/05/22 23:40
将二进制图片保存到服务器或本机
<pre name="code" class="csharp">T_Photo photo = new T_Photo();photo.Id = Guid.NewGuid();
//使用测试二进制图片流photo.ImageStream = ctx.T_Photo.Where(x => x.Id == new Guid("E338D4DB-F04C-4819-BE5D-005349344570"))
.First().ImageStream;//设置文件路径var filePath = System.Web.HttpContext.Current.Server.MapPath("~/files/");var fileSubPath = "PhotoImage/"+DateTime.Now.ToString("yyyyMMdd")+"/";var fileFullPath = Path.Combine(filePath, fileSubPath);var url = "";if (!Directory.Exists(fileFullPath)){ Directory.CreateDirectory(fileFullPath);}//图片保存格式fileFullPath = fileFullPath + photo.Id + ".jpeg";//将二进制图片保存到服务器System.IO.MemoryStream ms = new System.IO.MemoryStream(photo.ImageStream);System.Drawing.Image img = System.Drawing.Image.FromStream(ms);img.Save(fileFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);//将图片地址保存到数据库url = fileFullPath.Replace(System.Web.HttpContext.Current.Server.MapPath("~"),"").Replace("\\", "/");photo.ImageUrl = url;T_Photo.Add(photo);SaveChanges();//保存数据
0 0
- 二进图片保存到本地或服务器
- 图片自动保存到本地服务器
- 远程图片自动保存到本地服务器
- html5 保存图片到服务器本地
- 获取本地图片或拍照并保存到本地
- 保存图片到本地
- 图片保存到本地
- 图片保存到本地
- 保存图片到本地
- 图片保存到本地
- 使用URLConnection下载文件或图片并保存到本地
- 使用urlconnection下载文件或图片并保存到本地
- 使用urlconnection下载文件或图片并保存到本地
- ASP 远程图片自动保存到本地服务器
- 如何从服务器的图片保存到本地
- jsp获取远程图片保存到本地服务器上方法
- android 从服务器下载图片,并保存到本地
- flex图片剪切示例--预览、保存到本地、保存到服务器
- Redis 延迟产生的主要原因分析
- 让Hive支持行级insert、update、delete
- 软件架构漫谈笔记
- C++指针数组与数组指针的比较
- 电脑快捷键
- 二进图片保存到本地或服务器
- git命令
- MyEclipse+Tomcat+MAVEN 学习搭建
- TCP/IP详解(六)---UDP:用户数据报协议
- 整合营销的必要性
- c++实验6--数组操作
- dirname(__FILE__) 的使用总结
- Identify Linux File System Type
- 在Powerpoint幻灯片里显示总页数