首页调用相册获取图片,把图片路径存在storage里面,另一个页面获取该缓存路径,读取该图片的时候报错,然后电脑与手机的连接也直接断开了。我把代码贴出来,帮忙看看,谢谢~
这是代码:
mui.plusReady(function(){
window.addEventListener('GetAltasPicture', function(e){
UsercenterAltasClipGetPicture();
});
function UsercenterAltasClipGetPicture(){
var url = plus.storage.getItem('PicturePath');
var path=plus.io.convertLocalFileSystemURL(url);
var newurl = plus.io.convertAbsoluteFileSystem(path);
plus.io.resolveLocalFileSystemURL( newurl, function( entry ) {
entry.file( function(file){
console.log(file.name);
console.log(file.size);
console.log(file.type);
if(!/image\/\w+/.test(file.type)){
mui.alert("请确保文件为图像类型");
return false;
}
var reader = new plus.io.FileReader();
//reader.readAsDataURL(file);
//console.log(reader)
reader.onload = function(e){
console.log(e);
console.log( "Read success" );
console.log( this.result );
}
} );
}, function ( e ) {
mui.alert( "Resolve file URL failed: " + e.message );
} );
}
});
这是控制台输出的内容:
[LOG] : _doc/IMG_3596.JPG
[LOG] : IMG_3596.JPG
[LOG] : 2263047
[LOG] : image/jpeg
[LOG] : [object Object]
[LOG] : Read success
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at com.pandora.console.core.ConsoleLauncher.main(ConsoleLauncher.java:44)
3 个回复
骑着猪上班 (作者)
第一次发问题,好像没发全,控制台输出是这样的:
‘[LOG] : _doc/IMG_3596.JPG’
‘[LOG] : IMG_3596.JPG’
‘[LOG] : 2263047’
‘[LOG] : image/jpeg’
‘[LOG] : [object Object]’
‘[LOG] : Read success’
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at com.pandora.console.core.ConsoleLauncher.main(ConsoleLauncher.java:44)
近水楼台
mark
lizhudong2011
我的也是一样,有些手机可以