开发者

Getting the correct headers automatically given a filetype in PHP

开发者 https://www.devze.com 2023-01-02 17:39 出处:网络
Sorry - looks like this is a duplicate of: How to get the content-type of a file in PHP? A few times I\'ve run into situations where I\'d like to be able to include a file using PHP, and depending

Sorry - looks like this is a duplicate of: How to get the content-type of a file in PHP?


A few times I've run into situations where I'd like to be able to include a file using PHP, and depending on the included filetype, ou开发者_如何学JAVAtput the appropriate headers. In the past I've just done this manually by switch/casing the extension type with the appropriate content-type headers.

However what I'm wondering now is if there's a function like

get_header($filename)

or maybe

get_contenttype($extension)

For example if I wanted to route all requests for media through a php file, I could use that function to output the correct headers.


finfo_file might help. There some more info on this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消