body:
<input type="file" id="img" type="file" onchange="up()" style=" 100%;height: 100%;position:absolute ;top: 0;left:0;opacity: 0;">
js:
imgData=''; | |
code=26; | |
function up(){ |
|
var img=document.getElementById('img'); | |
var imgFile = new FileReader(); | |
imgFile.readAsDataURL(img.files[0]); | |
imgFile.onload = function () { | |
imgData = this.result; //base64数据 | |
// imgShow.setAttribute('src', imgData); | |
// conte.value = imgData; | |
if(imgData){ | |
zp='1' | |
//$api.dom('#xzzp').setAttribute("src",ret.base64Data) | |
document.getElementById('xzzp').setAttribute("src",imgData) | |
} | |
} | |
} |