简体   繁体   English

在Javascript中将byte []转换为Base64字符串

[英]Convert byte[] to Base64 string in Javascript

我曾经使用EntityDataSource渲染数据,并且曾经将客户图像作为字节存储在数据库中,问题是我如何将该字节转换为.aspx页面本身上的base64并将其用作图像src,有什么方法可以做到这一点在javascript中。

Why do you need to convert a byte[] to base64 string? 为什么需要将byte []转换为base64字符串? This won't allow you showing the image on the page. 这将不允许您在页面上显示图像。 You could write a generic handler (.ashx) that will query the database, fetch the image bytes and write them to the response stream. 您可以编写一个通用处理程序 (.ashx),该查询将查询数据库,获取图像字节并将其写入响应流。 Then you simply instruct your image src property to this generic handler. 然后,您只需将您的图像src属性指示给该通用处理程序即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM