简体   繁体   English

访问Apache的Mime-Type到扩展映射

[英]Accessing Apache's Mime-Type to Extension Mapping

Does PHP expose Apache's Mime-Type to extension mapping in any way shape or form. PHP是否以任何形式或形式将Apache的Mime-Type暴露给扩展映射。

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. 也就是说,Apache通常有一个文件扩展名列表(.gif,.pdf),它在一个通常称为mime.types的文件中映射到Mime-Types列表(image / gif,application / pdf等)。 Is there anyway to get a list of these mapings for the current running apache process via PHP? 无论如何通过PHP获取当前运行的apache进程的这些映射列表?

Lacking that, is there a way for PHP to ask Apache which mime.type file it's using? 缺乏这种,PHP是否有办法向Apache询问它使用的mime.type文件?

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: 你可能正在运行php作为CGI,但是如果你使用mod_php并且可以通过url访问该文件,你可以看看:

http://us2.php.net/manual/en/function.apache-lookup-uri.php 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') 或者,如果您不受openbasedir限制的限制,您可以循环遍历file('/usr/local/apache2/conf/mime.types')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM