refactored file type identification by using php's internal finfo