3 回答
TA贡献1830条经验 获得超9个赞
var myfile = document.getElementById('file');
var List = document.getElementsByClassName('list')[0];
myfile.onchange = function(){
var files = this.files;
for(var i = 0;i<files.length;i++){
var oFReader = new FileReader();
oFReader.readAsDataURL(files[i]);
oFReader.onload = function (oFREvent) {
console.log(oFReader);
var oLi = '<li><img src="'+oFREvent.target.result+'"><span class="close" onclick="closeli(this)" >×</span></li>';
List.innerHTML+=oLi;
};
}
}
oFREvent.target.result为base64地址,直接赋给src就行了
添加回答
举报