4

My Requirement is to upload only files that ends with.pdf extension in Angular 2 is there any method to find the extension or like any split method in java.

2

1 Answer 1

12

you can use split with pop for the file extension :

$(this).fileName.split('.').pop(); 
1
  • 2
    I did by like this e.target.files[0].name.substr( e.target.files[0].name.lastIndexOf('.') + 1)!="jpg"
    – Guvaliour
    Mar 6, 2018 at 13:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.