springboot+thymleaf文件上传后显示缩略图

<input id="file1" name="filename" type="file" />
<img id="img1" src="" style="width:200px;height:160px;">

<script language="javascript">
  $(function(){
    $("#file1").on("change",function(){
      var file=this.files[0];
        if(this.files && file){
           var reader=new FileReader();
           reader.onload=function(e){
           $("#img1").attr("src",e.target.result);
           }
          reader.readAsDataURL(file);
        }
    });
  });
</script>

猜你喜欢

转载自www.cnblogs.com/lr12339/p/9303119.html