gpt4 book ai didi

ASP.NET MVC : Use byte array as source of IMG tag through ViewData?

转载 作者:行者123 更新时间:2023-12-02 18:24:11 26 4
gpt4 key购买 nike

我在服务器端有一个图像的字节数组。我的“查看”页面上有一个 img 标签。

我想知道如何能够使用字节数组作为 img 标签的图像源。

我正在检索模型中的字节数组,将其传递回我的 Controller 方法,然后我想以某种方式将其存储在 ViewData 中。然后在 View 页面的 $(document).ready jQuery 函数中以某种方式将该字节数组设置为我的 IMG 标记的源。

这可能吗?

最佳答案

你应该能做到。只需将字节数组转换为 Base64 数字字符串,然后将 imge src 属性设置为编码图像即可。 See this question and answer.

关于ASP.NET MVC : Use byte array as source of IMG tag through ViewData?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4464030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com