我想用html上传图片,但总是失败。我通过console.log进行检查,并生成以下消息。图片无法显示在 Android 4.0.4
07-31 19:09:07.071: I/Web Console(16417): size:66797 at file:///android_asset/www/index.html:18
07-31 19:09:07.091: I/Web Console(16417): lastModifiedDate:Tue Jul 30 2013 03:44:18 GMT+0700 (WIT) at file:///android_asset/www/index.html:18
07-31 19:09:07.101: I/Web Console(16417): fileSize:66797 at file:///android_asset/www/index.html:18
07-31 19:09:07.111: I/Web Console(16417): name:1375130658314.jpg at file:///android_asset/www/index.html:18
07-31 19:09:07.121: I/Web Console(16417): type: at file:///android_asset/www/index.html:18
07-31 19:09:07.121: I/Web Console(16417): fileName:1375130658314.jpg at file:///android_asset/www/index.html:18
07-31 19:09:07.121: I/Web Console(16417): webkitSlice:function webkitSlice() { [native code] } at file:///android_asset/www/index.html:18
我发现“type”属性是空的。它发生在Android 4.0.4。
但4.1.2和4.1.3是可以的。
这个问题有什么线索吗?
-
Image preview exampleoFReader = new FileReader(),
rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;
oFReader.onload = function (oFREvent) {
document.getElementById('preview').src = oFREvent.target.result;
};
function loadImageFile() {
if (document.getElementById("uploadImage").files.length === 0) { return; }
var oFile = document.getElementById("uploadImage").files[0];
for(var x in oFile)
console.log(x+":"+oFile[x]);
oFReader.readAsDataURL(oFile);
}