从字节数组设置 img src [英] Set img src from Byte Array

查看:36
本文介绍了从字节数组设置 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 替换为图像类型,并将 [your byte array] 替换为您的 字节数组.如果尚未将其转换为 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]">

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

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