app开发之上传头像

//html结构

 

//js代码

function getFileContent() {

var reader = new FileReader();

var file = document.querySelector("#myFile").files;

reader.readAsDataURL(file[0]);

reader.onload = function() {

//展示

document.getElementById('re_img').src = reader.result;

localStorage.setItem('receipt', reader.result);

console.log(localStorage);

//console.log(document.getElementById('expense'));

}

};

你可能感兴趣的:(app开发之上传头像)