function getFilePath(filePath) {
if (navigator.userAgent.indexOf("MSIE")!=-1){
readFileIE(filePath);
}else if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Mozilla")!=-1){
readFileFirefox(filePath);
}else{
alert("Not IE or Firefox (userAgent=" + navigator.userAgent + ")");
}
}
function readFileIE(filePath) {
alert(document.getElementById("filePath").value)
}
function readFileFirefox(filePath) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert('路径错误!');
return;
}
/*console.log('value: ' + document.getElementById('filePath').value);
console.log('files.length: ' + document.getElementById('filePath').files.length);
console.log('fileName: ' + document.getElementById('filePath').files.item(0).fileName);
console.log('fileSize: ' + document.getElementById('filePath').files.item(0).fileSize);
console.log('dataurl: ' + document.getElementById('filePath').files.item(0).getAsDataURL());
console.log('data: ' + document.getElementById('filePath').files.item(0).getAsBinary());
console.log('datatext: ' + document.getElementById('filePath').files.item(0).getAsText("utf-8")); */
alert(filePath.value);
}
js 获取file
最新推荐文章于 2024-07-01 18:23:48 发布