如何制作可下载的内容 [英] how to make downloadable content

查看:74
本文介绍了如何制作可下载的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将图像存储在数据库中作为字节数组。我想在点击按钮后在页面中打开图像。我已经尝试了response.binarywrite()方法,保持页面内容类型=图像但不能保存在jpg中或jpeg format.so如何在c#?

I store images in database as byte array.I want to open the image in a page after clicking button.I have tried response.binarywrite() method keeping the page content type="image" but can not save that in jpg or jpeg format.so how to do in c#?

推荐答案

在下载图片页面中使用以下代码:

Use the below code in the download picture page:
string strFileName ="pic.jpg";
byte[] bytes = // get byes from the database table using your DB code/function
Response.Clear();
Response.AppendHeader("Content-Disposition", "filename=" + strFileName);
Response.AppendHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
Response.End();


这篇关于如何制作可下载的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆