PHP base64解码函数无法解码base64图像字符串
php base64 decode function is unable to decode base64 image string
since ie7
&默认情况下,ie8
无法解码base64图像字符串,我正在寻找另一种方法来实现它。在谷歌上搜索了这个问题后,我在http://dean.edwards.name/weblog/2005/06/base64-ie/上找到了一个很好的教程。
据我所知,解码过程由两个短脚本组成,如下所示:
。
按作者指示命名为base64.php
<?php
$data = split(";", $_SERVER["QUERY_STRING"]);
$type = $data[0];
$data = split(",", $data[1]);
header("Content-type: ".$type);
echo base64_decode($data[1]);
?>
B。javascript
,插入到嵌入base64图像字符串的页面头部标签内,最后将图像字符串传递给base64.php
进行处理&解码。
<script type="text/javascript">
// a regular expression to test for Base64 data
var BASE64_DATA = /^data:.*;base64/i;
// path to the PHP module that will decode the encoded data
var base64Path = "base64.php";
function fixBase64(img) {
// check the image source
if (BASE64_DATA.png(img.src)) {
// pass the data to the PHP routine
img.src = base64Path + "?" + img.src.slice(5);
}
};
// fix images on page load
onload = function() {
for (var i = 0; i < document.images.length; i++) {
fixBase64(document.images[i]);
}
};
</script>
不幸的是,php base64解码函数无法解码图像字符串为ie7
&在我的例子中是ie8
。
我的文档类型是DTD XHTML 1.0 Transitional
&charset=utf-8
。
你知道这里出了什么问题吗?
演示链接:
base64-string-without-php-decoder: http://silentpond.eu5.org/base64-string-without-php-decoder.php
base64-string-with-php-decoder: http://silentpond.eu5.org/base64-string-with-php-decoder.php
谢谢,
在IE中,至少在版本8或更早的时候。url的最大长度约为2047字节。更多信息请访问:http://support.microsoft.com/kb/208427
相关文章:
- 从Base64 Ionic编码和解码图像
- php中javascript解码中的base64编码
- 将Base64音频文件Mp3解码为可播放的Mp3
- 如何使用Java解码由window.btoa编码的base64图像
- Base64解码不适用于二进制数据
- 如何使用javascript将数据:image/png:base64.解码为真实图像
- 在JavaScript(浏览器端)中解码URL Safe Base64
- 编码然后在 base64 中解码不会输出我的输入数组缓冲区
- Node.js无法从base64解码中解析JSON字符串
- 在 base64 中解码字符串并加载为数组 JS
- 如何将 base64 音频数据解码为 WAV 格式
- PHP base64 编码的响应在 Javascript 中无法正确解码
- 在javascript中通过php解码base64编码的字符串
- 使用angularJS中的Base64解码对字符串进行解密
- base64解码的图像不下载
- 如何使base64解码函数解码本地语言中的字符串
- Javascript Base64解码失败
- PHP base64解码函数无法解码base64图像字符串
- 我如何将base64解码图像添加到openlayer地图
- 如何在Node.js中将base64解码为图像文件