JS 预览本地文件生成浏览器可识别的URL

function getObjectURL(file) {  
          var url = null ;   
          if (window.createObjectURL!=undefined) {  
            url = window.createObjectURL(file) ;  
          } else if (window.URL!=undefined) {   
            url = window.URL.createObjectURL(file) ;  
          } else if (window.webkitURL!=undefined) {  
            url = window.webkitURL.createObjectURL(file) ;  
          }  
          return url ;  
    } 

猜你喜欢

转载自blog.csdn.net/tyjlearning/article/details/108777309