js 获取 input file 文件 附给 image src

var a=document.querySelector('input[type=file]');

a.onchange = function (e) {

//var reader = new FileReader();
//reader.readAsDataURL(a.files[0]);
//reader.onload = function (event) {
//img.src = event.target.result;
//};

var reader = new FileReader();
reader.readAsArrayBuffer(a.files[0]);
reader.onload = function (event) {
// blob stuff
var blob = new Blob([event.target.result]); // create blob...
window.URL = window.URL || window.webkitURL;
var blobURL = window.URL.createObjectURL(blob); // and get it's URL
var img=new Image();

img.src=blobUrl;

document.body.appendChild(img);
};
}

上一篇:JZ2440开发笔记(6)——存储控制器


下一篇:Android Drawable 关于selector中state_pressed="true"的位置顺序