ITPub博客

首页 > 数据库 > Oracle > .net图片二进制转换,oracle图片存取 远方

.net图片二进制转换,oracle图片存取 远方

Oracle 作者:xcq170 时间:2014-01-17 21:35:12 0 删除 编辑

一、将图片保存在oracle数据库中

使用字段类型blob

在保存图片时,由于是保存数组byte[] img,所以需要显示设置参数的类型。例如:

new OracleParameter(":Photo", OracleDbType.Blob, img.Length, img, ParameterDirection.Input),

其他操作和普通字段一样。

 

二、将图片转成byte[]

 上传一个文件,获取文件对象,HttpPostedFile file = context.Request.Files["Filedata"];

 int intlenght = file.ContentLength;
 //图片保存为二进制字节
 byte[] arrBt = new byte[intlenght];

 Stream strm = file.InputStream;
 strm.Read(arrBt, 0, intlenght);

 

三、Photo.ashx中直接输出byte数组

context.Response.BinaryWrite((byte[])(dt.Rows[0][0]));

 

四、页面中调用图片

img alt="照片" src="ashx/Photo.ashx?Id=222

<!-- 正文结束 -->

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21829320/viewspace-1116734/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-06-06

最新文章