简体   繁体   English

如何将 blob 图像从数据库转换为 html 图像 src

[英]How can I convert blob image from database to html image src

I have a blob field in the database which stores image blob.我在存储图像 blob 的数据库中有一个 blob 字段。 I want to convert this to an image in the html image src tag.我想将其转换为 html 图像 src 标签中的图像。 How can this be done, i am using ASP.NET MVC c# as my backend.如何做到这一点,我使用 ASP.NET MVC c# 作为我的后端。

One way is to convert it to Base64String.一种方法是将其转换为 Base64String。 First convert it to ByteArray then you can get Base64String.首先将其转换为ByteArray,然后您可以获得Base64String。 for example:例如:

var imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffer)}";

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

相关问题 如何显示来自mysql(blob)中数据库的图像到网页中的“图像”控件 - How can i show an image from a database in mysql(blob), to an “Image” control in a web page 如何将 BLOB 转换为图像 - How to convert BLOB to Image 我正在尝试从我的数据库中显示图像,但图像不会填充img html属性的src - I'm trying to display an image from my database, but the image wont populate the src of the img html attribute 我怎样才能得到图像src? - How can I get the image src? 如果图像ID未知,如何显示数据库中的图像(存储为BLOB)? - How to display image from database (stored as BLOB), if the image ID is not known? 如何将Blob值转换为图像 - How to convert Blob value to Image 我如何旋转数据库中的图像 - how can i rotate image from database 如何读取数据库中的byte []并将其转换为图像? - How can I read a byte[] out of the database and convert it to an image? 如何将图像保存到 Azure Blob 并使用特定字段命名并返回 Blob Url 并将其保存到 .net core 2.2 中的数据库 - How can i save an image to a Azure Blob and name it with specific fields and return the Blob Url and save it to database in .net core 2.2 从openfiledialog获取名称后,如何在访问数据库中存储映像BLOB? - How do I store a image BLOB in an access database after getting the name from openfiledialog?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM