Cam
Cam

Reputation: 15234

Getting the correct headers automatically given a filetype in PHP

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, output 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.

Upvotes: 1

Views: 2264

Answers (1)

Brendan Long
Brendan Long

Reputation: 54242

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

Upvotes: 1

Related Questions