我正在尝试访问移动设备上的相机和相册并获取所选图像。我用下面的代码做到了。我的问题是,它生成图像数据,我必须将其传输到另一个页面,但是由于生成的字符串的大小,我不能使用 URL 参数。它向我显示了错误:[404] Request-URI Too long
. 如何将信息传递到其他页面?
这是代码:http: //jsfiddle.net/8u426/
JS:
<script>
oFReader = new FileReader();
oFReader.onload = function (oFREvent) {
document.getElementById("fotoImg").src = oFREvent.target.result;
document.getElementById("fotoImg").style.visibility = "visible";
var screenHeight = screen.availHeight;
screenHeight = screenHeight - 220;
document.getElementById("fotoImg").style.height = screenHeight;
document.getElementById("stringImg").innerText = "Data Image: " + oFREvent.target.result;
};
$(function() {
$("input:file").change(function (){
var input = document.querySelector('input[type=file]');
var oFile = input.files[0];
oFReader.readAsDataURL(oFile);
});
});
</script>
更新:
问题是:如果我尝试打开一个新页面,将数据图像字符串作为 URL 中的参数传递(使用“?”)。新页面将显示我提到的 404 错误,因为字符串太长。