tags:

views:

47

answers:

3

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 value 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?

+1  A: 

Maybe case sensitive

Bolu
+1  A: 

Check the case of the file extensions (UPPER vs lower vs miXeD)

Dan Iveson
+1  A: 

Try the following:

if (ext.indexOf(FileUploadval.toLowerCase().substring(FileUploadval.toLowerCase().lastIndexOf('.') + 1)) == -1) {
}
Zafer