If you host your application on linux, you should convert extension to lower case to match strings in $allowedExts
, because linux is case sensitive (and not just linux).
Check this How to track execution time of each line / block of lines / methods in PHP? to be able to run script step by step and see, where the problem is.