better file-extension check, doesn't rely on preg_match

this avoids preg_match altogether. doesn't get tripped by "poorly_named_file.jpg.mp3"