Home > Mobile >  Image as byte array does not get visualzied with the 'src' attribute of 'img' el
Image as byte array does not get visualzied with the 'src' attribute of 'img' el

Time:09-26

I have this image that I receive as byte[], but then as I try to display it using the src attribute of the img element as data:image/png;base64,[byte array here] it displays System.Byte[] and not the actual array, therefore the image does not get displayed.
Below are two images of my code and the result of it My code and what I receive in my object that contains the image byte array

The result of the code

CodePudding user response:

You need to convert the byte array to base64 string. You can use Convert.ToBase64String method.

<img src="data:image/png;base64,@Convert.ToBase64String(card.Image)" />
  • Related