在rails中显示base64编码的图像 [英] Display base64 encoded image in rails
本文介绍了在rails中显示base64编码的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将base64图像发送到我的控制器,并按原样保存它. 现在,我需要显示该图像. 这是我要显示的内容,但图像没有显示:
I'm sending a base64 image to my controller and I'm saving it as it is. Now I need to display that image. This is what I'm doing to display but image is not showing up:
<img src="<%= Base64.decode64(@data_obj.first.desc) %>"/>
为了进行编码,我正在使用此Java脚本功能encodeURIComponent();
In order to encode I'm using this java-script function encodeURIComponent();
我的编码图像格式:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/........
推荐答案
您不需要解码base64
You don't need to decode the base64
<img src="data:image/jpeg;base64,..." />
应该工作
这篇关于在rails中显示base64编码的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文