html代码

<input type="file" name="file"  id="file" >
<img src=""  >

 

 

js代码

    $("#file").bind("change",function(){
            var url = null;
            if(window.createObjectURL != undefined) {
                url = window.createObjectURL(this.files[0]);
            } else if(window.URL != undefined) {
                url = window.URL.createObjectURL(this.files[0]);
            } else if(window.webkitURL != undefined) {
                url = window.webkitURL.createObjectURL(this.files[0]);
            }
            $("#img").attr("src",url);
        })

 

相关文章:

  • 2022-02-06
  • 2021-07-04
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
猜你喜欢
  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案