`
nvry
  • 浏览: 316622 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

IE浏览器上传文件时本地路径变成”C:\fakepath\”的问题

    博客分类:
  • view
 
阅读更多
	//判断浏览器类型 2          
	var isIE = (document.all) ? true : false; 3         
	var isIE7 = isIE && (navigator.userAgent.indexOf('MSIE 7.0') != -1);          
	var isIE8 = isIE && (navigator.userAgent.indexOf('MSIE 8.0') != -1);         
	var isIE6 = isIE && (navigator.userAgent.indexOf('MSIE 6.0') != -1);         
	var file = document.getElementById("uploadFile");  
	var path = null;
	if (isIE7 || isIE8) { 
		file.select();//获取欲上传的文件路径             
		path = document.selection.createRange().text;            
		document.selection.empty();
	} 
	var filepath = document.getElementById("uploadFile").value;
	if (isIE6) {
		path = filepath; 
	}
	
	alert("--------------------"+path);

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics