I want to find out if a variable value contains in second string. My code is
if (ext.indexOf(FileUploadval.substring(FileUploadval.lastIndexOf('.') + 1)) == -1) {
}
where ext have va开发者_StackOverflow社区lue pdf,doc,dox,xls,xlsx,ppt,pptx and when i try xls or xlsx file it goes in if condition but when i try doc or pdf it doesnot go in if condition. what can be the problem?
Maybe case sensitive
Check the case of the file extensions (UPPER vs lower vs miXeD)
Try the following:
if (ext.indexOf(FileUploadval.toLowerCase().substring(FileUploadval.toLowerCase().lastIndexOf('.') + 1)) == -1) {
}
精彩评论