Accessing Apache's Mime

Does PHP expose Apache's Mime-Type 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')

链接地址: http://www.djcxy.com/p/46926.html

上一篇: 如何获取MIME类型的文件扩展名(内容类型)

下一篇: 访问Apache的Mime