Getting MIME type of a file

The PHP manual is sending me in circles. It says mime_content_type() has been deprecated and to use Fileinfo. The page on Fileinfo sends me back to mime_content_type!

The Fileinfo page seems to suggest finfo_file!

If you are sure you’re only ever working with images, you can check out the getimagesize() PHP function, which attempts to return the image mime-type.

or

If you want the mime type when you upload the files then you can use $_FILES[‘filename’][‘type’]

or

echo system('file -ib '. ‘test.php’);

Thanks guys. It’s a file on the server - in most cases probably a PDF. I’m trying to make sense of finfo_file()…