日期:2014-05-17 浏览次数:20401 次
if (!string.IsNullOrEmpty(Request["employeeId"])) //需要显示照片的页面传递的员工id
{
string id = Request["employeeId"];
ArrayList paras = new ArrayList();
paras.Add(id);
DataSet data_temp = new DataSet();
data_temp = this.chaxun(paras);
try
{
Byte[] byteImg = (Byte[])data_temp.Tables[0].Rows[0]["photo1"];//把数据库中图片的二进制数据转换一个byte数组
Stream stream = new MemoryStream(byteImg);
System.Drawing.Bitmap img = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(stream, false); //转换成Bitmap
Response.Buffer = false;
Response.ContentType = "image/jpg";
Response.AddHeader("Content-Disposition", "attachment;filename=photo.jpg");//照片名称叫photo.jpg
Response.BinaryWrite(byteImg);//写入二进制流
Response.End();
}
catch
{
Response.End();
}
}