Mime Magic functions - how standard are they?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PHP List,

I would like to set up a function within my system that can test a file that a user has uploaded and determine what kind of file it is. My intention is to only handle a fairly small number of common file types*, so I don't think I need to build anything too robust.

Of course, I checked php.net, but was almost immediately confounded by what seems to be a transition from mime_content_type to Fileinfo. My confusion lies in the fact that on the one hand mime_content_type seems to be in the process of being depreciated, but at the same time, the Fileinfo functions seem to rely on PECL extensions which don't seem to be standard in every PHP installation.

At least, it seems like the PECL extensions are not present in my testing environment, which use default installation settings (via Ubuntu Feisty repositories).

When I tried to emulate the example on this page:
http://php.benscom.com/manual/en/function.finfo-open.php

... It gave me an error indicating the class "finfo" could not be found.

I'm trying to build a system that will hopefully be portable without anyone having to reconfigure PHP in any way to get it running.

So, ultimately, what I'm wondering is, what should I be using in order to determine file MIME types that will be the most commonly installed on servers with PHP?

Thank you for any advice.

* The file types I will test for are most likely to be the following:
.txt, .pdf, .png, .gif, .jpg, .mp3, .ogg, .doc, .odt, .zip, .gz... maybe that's it.

--
Dave M G
Zend Studio 5.5
Ubuntu 7.04

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux