views:

18

answers:

1

Sorry - looks like this is a duplicate of: http://stackoverflow.com/questions/1232769/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.

+1  A: 

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

Brendan Long
Ah - cool. This looks like a dupe then. Thanks!
Cam