NYCPHP Meetup

NYPHP.org

[nycphp-talk] Determining mime type of data not a file

Scott Mattocks scott at crisscott.com
Wed Jan 25 11:18:31 EST 2006


Scott Mattocks wrote:
> Thanks Chris and Anderw.
> 
> I found the answer I was looking for in the fileinfo PECL extension 
> (http://pecl.php.net/package/fileinfo). With this extension I can do the 
> following:
> 
> // Get the image data (see previous message for psuedo code)
> $fi = finfo_open(FILEINFO_MIME);
> $contentType = finfo_buffer($fi, $image);
> // Set the headers and output the message.

For anyone else that is interested, you can alternatively do this:

$finfo = new finfo(FILEINFO_MIME);
$contentType = $finfo->buffer($image);

Scott



More information about the talk mailing list