file在IE8里的路径错误更改方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>获取FILE的值</title>
<script src="../jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
</head>
<body>
<input id="click" type="button" value="获取FILE的值" />
<div>
<input type="file" /><input class="add" type="button" value="+" /><input class="jian" type="button" value="-" />
</div>
<div>
<input type="file" /><input class="add" type="button" value="+" /><input class="jian" type="button" value="-" />
</div>
</body>
</html>
<script type="text/jscript">
$("#click").click(function() { $(":file").each(function() { alert(getPatsh(this)) }) });
//获取正确的路径 return 路径值
function getPath(obj) {
if (obj) {
if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
obj.select();
return document.selection.createRange().text;
}
else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
</script>