关键点:
img.src = URL.createObjectURL(file.files[0]);
准备一个 #file input[type=file]
var fImg = document.getElementById('file');
fImg.onchange = function(){
var tb = document.querySelector('#tblQRResult');
for(var i = 0 , l = this.files.length;i<l;i++){
addImage(tb,this.files[i]);
}
}
function addImage(tb,imgFile){
var tr = document.createElement('tr'),
td1 = document.createElement('td'),
td2 = document.createElement('td'),
td3 = document.createElement('td'),
img = document.createElement('img'),
s = URL.createObjectURL(imgFile);
img.src = s;
// img.style.height = '120px'
td1.appendChild(img);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tb.appendChild(tr);
}