Accessing Apache's Mime-Type to Extension Mapping
Does PHP expose Apache's Mime-Ty开发者_如何学JAVApe to extension mapping in any way shape or form.
That is, Apache typically has a list of files extensions (.gif, .pdf) that it maps to a list of Mime-Types (image/gif, application/pdf, etc.) in a file typically called mime.types. Is there anyway to get a list of these mapings for the current running apache process via PHP?
Lacking that, is there a way for PHP to ask Apache which mime.type file it's using?
You're probably running php as a CGI, but if you are using mod_php and the file is accessible via a url, you can take a look at:
http://us2.php.net/manual/en/function.apache-lookup-uri.php
Or if you aren't limited by openbasedir restrictions, you could loop over file('/usr/local/apache2/conf/mime.types')
精彩评论