jinsuo
<body>
 <input type="file" name="file" id="file" onClick="$(\'#file\').click();" style="display:block" 
       onChange="var img=getObjectURL(this.files[0]);$(\'#myimg\').attr(\'src\',img)" />
<img id="myimg" src="" style="pointer-events: none;"/>

</body>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">

    function getObjectURL(file) {
        var url = null ;
        if (window.createObjectURL!=undefined) { // basic
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    };

</script>

 

分类:

技术点:

相关文章:

  • 2021-05-17
  • 2021-07-09
  • 2021-11-20
  • 2021-05-31
  • 2022-01-06
  • 2021-11-29
  • 2021-12-31
  • 2021-12-31
猜你喜欢
  • 2021-12-06
  • 2021-11-29
  • 2021-06-05
  • 2021-11-29
  • 2021-12-30
  • 2021-12-13
  • 2021-04-23
相关资源
相似解决方案