我有以下代码,IE和其他人之间的行为不同。 FileItem.getName()总是无法通过我的函数来检查IE浏览器中的无效文件名。别人好!
FileItem item =xxxx;
String fileName = item.getName();
IsLegalFileName(fileName);
// it always show invalid file name from below function
public static boolean IsLegalFileName(String str){
boolean isValid = true;
int i;
String[] badChars = {"/","\\",":","*","?","\"" ,"<",">"};
for (i = 0; i < badChars.length; i++){
if (str.indexOf(badChars[i]) >= 0)
{
isValid = false;
break;
}
}
return isValid;
}