本篇文章是对使用JS获取IE上传文件路径的实现代码进行了详细的分析介绍
需要的朋友参考下
复制代码 代码如下:
function validateFileSize(id maxsize) {
var btnsave = documentgetElementById("Button");
btnsavedisabled = false;
var filepath = "";
var fileupload = documentgetElementById(id);
if (fileuploadvaluelength < ) { alert(请选择文件!); return; }
var agent = windownavigatoruserAgent;
if (documentall) {
var isIE = agentindexOf(MSIE ) != ;
var isIE = agentindexOf(MSIE ) != ;
//IE和IE获得文件路径
if (isIE || isIE) {
fileuploadselect();
filepath = documentselectioncreateRange()text;
}
//IE获得文件路径
else
{ filepath = filevalue; }
//PageMethodsValidateFile(filepath maxsize ieCallBack);
alert(filepath);
}
if (agentindexOf("Firefox") >= ) {
alert("FF");
alert(getValue());
return false;
if (fileuploadfiles) {
var size = fileuploadfiles[]fileSize;
if (size > parseInt(maxsize)) {
fileuploadparentNodeinnerHTML = <input type="file" name=" + fileuploadname + " id=" + fileuploadid + " onchange="disableSave(this);"/> ;
alert("文件超过大小!");
}
else { alert("文件上传成功!"); }
}
}
}