This article provides a detailed analysis of the implementation code for getting the path of the IE uploaded file using JS. For more information, see
The Code is as follows:
Function validateFileSize (id, maxsize ){
Var btnsave = document. getElementById ("Button2 ");
Btnsave. disabled = false;
Var filepath = "";
Var fileupload = document. getElementById (id );
If (fileupload. value. length <5) {alert ('select a file! '); Return ;}
Var agent = window. navigator. userAgent;
If (document. all ){
Var isIE7 = agent. indexOf ('msie 7.0 ')! =-1;
Var isIE8 = agent. indexOf ('msie 8.0 ')! =-1;
// Obtain the file path from IE7 and IE8
If (isIE7 | isIE8 ){
Fileupload. select ();
Filepath = document. selection. createRange (). text;
}
// Obtain the file path from IE6
Else
{Filepath = file. value ;}
// PageMethods. ValidateFile (filepath, maxsize, ieCallBack );
Alert (filepath );
}
If (agent. indexOf ("Firefox")> = 1 ){
Alert ("FF ");
Alert (getValue ());
Return false;
If (fileupload. files ){
Var size = fileupload. files [0]. fileSize;
If (size> parseInt (maxsize )){
Fileupload. parentNode. innerHTML ='';
Alert ("the file size exceeds! ");
}
Else {alert ("File Uploaded successfully! ");}
}
}
}