js中获取文件的本地路径的代码

论坛 期权论坛 脚本     
匿名技术用户   2021-1-5 09:22   11   0
<pre name="code" class="javascript">$(".addimg-LiuLan").change(function(){
  var objUrl = getObjectURL(this.files[0]) ;//获取文件
  console.log("objUrl = "+objUrl) ;
  if (objUrl) {
   $(".addimg-Kuang").attr("src", objUrl) ;
  }
 }) ;


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

 

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP