0

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?

3 Answers 3

1

Maybe case sensitive

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

Try the following:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.