<input class="weui_uploader_input" name='image' type="file" accept="image/*" multiple />
//上传控件,选择后更改背景图
<script>
$("input[type='file']").change(function(){
var file = this.files[0];
if (window.FileReader) {
var reader = new FileReader();
reader.readAsDataURL(file);
//监听文件读取结束后事件
reader.onloadend = function (e) {
$(".weui_uploader_file").css("background-image","url("+e.target.result+")");
//e.target.result就是最后的路径地址
};
}
});
</script>
网友评论