如何在界面上显示本地图片

来源:互联网 发布:linux安装yum命令 编辑:程序博客网 时间:2024/05/12 08:12
<html>
    <head>
  <script type="text/javascript">
          function getFullPath(obj){ 
     if(obj){ 
      //ie 
      if (window.navigator.userAgent.indexOf("MSIE")>=1) { 
       obj.select();
       return document.selection.createRange().text; 
      } 
      //firefox 
      else if(window.navigator.userAgent.indexOf("Firefox")>=1){ 
       if(obj.files){ 
       return obj.files.item(0).getAsDataURL(); 
       } 
       return obj.value; 
      }
    return obj.value; 
    } 
          } 
          </script>
    </head>
    <body>
        <input type="file" onchange="document.getElementById('img').src=getFullPath(this);" />
        <img id="img" />
    </body>
</html>
原创粉丝点击