I guess I want to ultimately build out a script that will force the browser in a sense to prompt for a download rather than go directly to the file and I want to do it based off of db entries so its obfuscated just that little bit more. My problem is I can only find a mime type or 2 to work with but I want a fair shares worth. From doc to pdf, to mp3 to avi.. My script is going to run based off extensions of files and then output the proper header just need to know what header to put out with what type of file. Is there a common list of file types known to stream or open within a browser by default that I can just go by?
Share
File extensions are not exactly the most reliable way to determine the file type. You might be interested in doing some MIME guessing. If you app is hosted in Linux, you can benefit from the file command line tool with the
-ioption:Otherwise, PHP has a PECL extension called Fileinfo.
If you want to stick to file extensions, media types are approved by the IANA.
Update: Fileinfo is a native extension since PHP/5.3.0 (thus no need to install a third-party app). Usage example: