二进制流上传图片,预览,读取显示
2012-04-09 10:43
399 查看
上传图片并生成缩略图预览效果
getvalue() Function的定义在一下Javascript中:
ReadImage。aspx.cs
<div> <asp:FileUpload ID="FileUpload1" runat="server" CssClass="btn" Width="320px" onchange="getValue()" /> <asp:Button ID="btnAdd" runat="server" Text="Submit" ValidationGroup="AddPlat" CssClass="btn" Width="80px" OnClick="btnAdd_Click" /> <div id="t2" runat="server" style="width: 150px; height: 120px; visibility: hidden; display: none; border: solid 1px #CCC;"> <img alt="" id="t1" runat="server" src="" style="width: 150px; height: 120px; border: solid 1px #CCC; display: none;" /> </div> <asp:Image ID="imageSony" runat="server" BorderStyle="Solid" Width="150px" Height="120px" ImageUrl="" /> </div>
getvalue() Function的定义在一下Javascript中:
ReadImage。aspx.cs
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string imageid = "1"; if (Request.QueryString["itemid"] != null) { imageid = Request.QueryString["itemid"].ToString(); } int imgID = Int32.Parse(imageid); ShowImage(imgID); } } private void ShowImage(int itemID) { DataTable dt = new DataTable(); dt = srb.GetSonyItem(itemID);//获得数据源 byte[] b_image = (byte[])dt.Rows[0]["Picture"];//得到数据库二进制字段内容 if (b_image.Length > 0) { Byte[] byteImg = (byte[])dt.Rows[0]["Picture"]; Response.BinaryWrite(byteImg);//写入二进制流 Response.End(); } }
相关文章推荐
- js兼容火狐显示上传图片预览效果的方法(读取字节)
- asp.net 图片批量上传预览,在Silverlight页面中读取并滚动显示
- ASP.NET 上传图片至数据库并读取图片显示--二进制流方式
- ASP.NET MVC实现图片上传、图片预览显示
- ASP.NET 上传图片至数据库并读取图片显示
- 实现上传图片之后显示预览javaScript代码
- ASP.NET 上传图片至数据库并读取图片显示
- js兼容火狐显示上传图片预览效果的方法
- 使用asp.net将图片上传并存入SqlServer中,然后从SqlServer中读取并显示出来
- 上传图片到数据库,读取数据库中图片并显示(C#)
- 用onpropertychange事件显示图片上传前的预览
- EasyUI上传图片,前台预览,后台读取
- thinkphp+ueditor 上传图片显示:正在读取目录
- 上传图片以二进制插入到数据库,且读取显示
- input file文件上传(multiple)及FileReader:读取本地图片文件并显示
- H5上传图片前端预览显示
- 上传图片预览设置src不显示
- ASP.NET 上传图片至数据库并读取图片显示
- js实现图片上传前的预览,实现完美兼容Firefox3,IE6,IE7,IE8和IE9的显示问题
- ASP.NET MVC实现图片上传、图片预览显示