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

	//判断浏览器类型 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);

 

你可能感兴趣的:(Path)