从Byte Array设置img src [英] Set img src from Byte Array

查看:261
本文介绍了从Byte Array设置img src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个字节数组中设置 img src 属性。

I need to set the img src property from a byte array that I have in a Object.

<img id="profileImage">
    <spring:bind path="object.profilePicture">
        <input type="file" name="profilePicture" id="profilePicture" path="profilePicture">
    </spring:bind>

我需要在 img 在输入标签上方。

I need to display that byte array in the img above the input tag.

推荐答案

jpg 替换为类型的图像,以及 [你的字节数组] 与你的字节数组。如果还没有,你需要将它转换为 base64

Replace the jpg with the type of image, and [your byte array] with your byte array. You need to convert it to base64 if it isn't already.

<img id="profileImage" src="data:image/jpg;base64, [your byte array]">

这篇关于从Byte Array设置img src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆