<p><code>mime_content_type()</code> is deprecated.</p>

<p>How can I find the <code>MIME type</code> of a local file using <code>PHP5</code> but without using this deprecated method or the <code>PECL fileinfo</code> extension?</p>

<p>Edit: That's what I was afraid of.  It's unfortunate that they deprecated a built-in function in favour of one that requires an extension that isn't always available.</p>

[{'answer_id': 51116, 'author': 'Michael Pryor', 'author_id': 245, 'author_profile': 'https://Stackoverflow.com/users/245', 'pm_score': 2, 'selected': True, 'text': "<p>If you can't use the fileinfo extension, and you don't want to use mime_content_type, your options are limited.</p>\n\n<p>Most likely you'll need to do a lookup based on the file extension.  mime_content_type did something a bit more intelligent and actually looked for special data in the file to determine the mime type.</p>\n"}, {'answer_id': 51560, 'author': 'Jon Cram', 'author_id': 5343, 'author_profile': 'https://Stackoverflow.com/users/5343', 'pm_score': 0, 'selected': False, 'text': '<p>The <a href="http://getid3.sourceforge.met" rel="nofollow noreferrer" title="getId3">getID3()</a> library is a quick and easy works-most-of-the-time option. Originally named for a project to obtain MP3 ID3 data, the library does two hecks of a lot more than that and is quite convenient for all sorts of common or odd file meta data tasks.</p>\n\n<p>I\'ve used it to get the MIME types of files for online image and video tools. In all the testing I\'ve done I\'ve not seen getID3 get the MIME type wrong.</p>\n\n<p>I\'ve also used it to check if QuickTime videos have streaming hints. I mention  this as an example of versatility.</p>\n\n<p>A second more time consuming option is to roll your own MIME type checker as already suggested. If you have a MIME magic file you can go a little further than a lookup on the file extension by comparing the first n bytes of file data against a first-n-bytes to MIME type lookup table derived from your MIME magic file.</p>\n\n<p>A typical MIME magic file will contain in excess of 500 sets of MIME types which might result in slow comparisons (lots of checks to make). Hard-coding the 10 most common MIME type checks in your home rolled solution will help there.</p>\n'}]
['https://Stackoverflow.com/questions/51110', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']