Mime Magic functions - how standard are they?



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
.



Relevant Pages

  • php-4.3.4-Win + Apache2 + XP
    ... I am completely new to PHP and am finding installation the most ... I am doing a manualinstall of PHP. ... I have put DLLs in various places so that they "can ... Is it the Apache2 server? ...
    (alt.php)
  • php-4.3.4-Win + Apache2 + XP
    ... I am completely new to PHP and am finding installation the most ... I am doing a manualinstall of PHP. ... I have put DLLs in various places so that they "can ... Is it the Apache2 server? ...
    (comp.lang.php)
  • Re: [PHP] Is the GD module standard?
    ... I have been using the imagepng() function in my local testing ... I hadn't done any customization to my PHP set ... I went with the default set of installation options that Ubuntu ... Recently, I uploaded my site to a web hosting server, and the CAPTCHA ...
    (php.general)
  • Re: Problems with a new install
    ... I can get pages to be served by the installation, but what I'd also like to do is get PHPMyAdmin working. ... When I try to login to the PMA using a user/pass defined in the MySQL database, I get no error messages, but it just reloads the login page. ... When I try to run through the various buttons for the setup utility, it creates a zero-byte config.inc.php file in the config folder, and never shows anything more than the buttons on the page. ... I've given the IUSR_machinename account privileges to all the PHP folders, as well as the temp folder. ...
    (comp.lang.php)
  • Is the GD module standard?
    ... At first, I didn't understand that it was a module issue, because I thought the imagepng() function was standard in PHP. ... So my assumption that imagepngwill be available on any standard installation of PHP is wrong. ... Is it that my web hosting server is lacking in what can be expected for standard PHP features? ...
    (php.general)