PHP is language for webserver, it support very more functions.
With file, PHP also support very more function, full for you can code everything . You can refer to library of PHP.
Here, I am referring to how to get the type of files a simple way:
$extension = pathinfo($file_name, PATHINFO_EXTENSION);
Hope, it helpful to you.