springboot+thymleaf文件上傳後顯示縮略圖

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

 

<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>java

相關文章
相關標籤/搜索