public string DownImg(string guid)
{
Stream stream = new ComFunction().DownLoadStream(guid);
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
return JsonConvert.SerializeObject(bytes);
}$.ajax({
type: 'post',
dataType: 'json',
url: "/Issue/DownImg?guid=" + imglist[i].split('.')[0],
success: function (data) {
//将图片的Base64编码设置给src
$("#" + tab + "_img1").attr("src", "data:image/png;base64," + data);
$("#" + tab + "_img1").show();
}
});
图片二进制流显示到页面
Ajax请求返回图片 (二进制流)
欢迎分享,(联系QQ/微信:282625252)