如何显示json编码图像 - jquery signaturepad

时间:2016-05-19 16:40:27

标签: php json image signaturepad

我正在尝试显示已编码的图像。它看起来像是:

$('#country').change(function () {
 $('#hiddendiv').toggle($(this).find('option:selected').hasClass('warning'));
});

我试过了:

"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOQAAAA3CAYAAAAc\/eYMAAAAuUlEQVR4nO3TMQEAMAyAsPo33Z6TMI5EAQ+zQMb8DgAeQ0KIISHEkBBiSAgxJIQYEkIMCSGGhBBDQoghIcSQEGJICDEkhBgSQgwJIYaEEENCiCEhxJAQYkgIMSSEGBJCDAkhhoQQQ0KIISHEkBBiSAgxJIQYEkIMCSGGhBBDQoghIcSQEGJICDEkhBgSQgwJIYaEEENCiCEhxJAQYkgIMSSEGBJCDAkhhoQQQ0KIISHEkBBiSAgxJIQclyE3fsX77n0AAAAASUVORK5CYII="}

没有该部分的字符串:

base64-decode()

但没有结果。

我应该如何转换图像来显示它?感谢。

编辑:这个图像实际上是签名。我正在使用jquery签名板。它看起来像在数据库中:

data:image\/png;base64,

如何显示此签名?

1 个答案:

答案 0 :(得分:0)

刚刚通过img标记中的编码图像(替换/ \ with /):

<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAOQAAAA3CAYAAAAc/eYMAAAAuUlEQVR4nO3TMQEAMAyAsPo33Z6TMI5EAQ+zQMb8DgAeQ0KIISHEkBBiSAgxJIQYEkIMCSGGhBBDQoghIcSQEGJICDEkhBgSQgwJIYaEEENCiCEhxJAQYkgIMSSEGBJCDAkhhoQQQ0KIISHEkBBiSAgxJIQYEkIMCSGGhBBDQoghIcSQEGJICDEkhBgSQgwJIYaEEENCiCEhxJAQYkgIMSSEGBJCDAkhhoQQQ0KIISHEkBBiSAgxJIQclyE3fsX77n0AAAAASUVORK5CYII=">

JsFiddle