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);
};
}