document.getElementById("live").onchange = function () {
gen_base641();
};
function $_(id) {
return document.getElementById(id);
}
function gen_base641() {
var file = $_('live').files[0];
r = new FileReader(); //本地预览
r.onload = function(){
//alert($_('t'));
$_('t').style.backgroundImage = 'url('+r.result+')';
//$_('t').style.backgroundsize = 'contain';
//$_('t').style.zIndex="-1";
//background-image:url('image/live4.png')
//$_('t').src =r.result;
//$_('t').width=481;
//$_('t').height=345;
//$_('livediv').style.overflow = "hidden";
//$_('livediv')..style.setProperty('height','300px');
// $_('livediv').style.[height] = "300px";
// $_('livediv').style[background-repeat] = "no-repeat";
//$_('livediv').style.[background-position] = "center top";
}
r.readAsDataURL(file); //Base64
}
使用JS解析成base64编码再输出图片
最新推荐文章于 2024-06-17 14:29:33 发布