note 50834 deleted from ref.mime-magic by nlopess
| From: | nlopess@php.net | Date: | Fri, 11 Mar 2005 19:47:45 +0000 |
| Subject: | note 50834 deleted from ref.mime-magic by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86286@lists.php.net to get a copy of this message | ||
Note Submitter: phpsite at michael dot mailshell dot com
----
From the top of this php (LXX. Mimetype Functions):
This extension has been deprecated as the PECL extension fileinfo provides the same functionality
(and more) in a much cleaner way.
I call shenanigans. According to Google with several hours of my time, there is not a page on the
internet which contains docs to this extension.
From phpinfo():
fileinfo support => enabled
# cat test.php
<?
$fileName = '/tmp/image.jpg';
$fInfo = new finfo(FILEINFO_MIME);
$mimeType = $fInfo->file($fileName);
echo $mimeType;
?>
# php test.php
Fatal error: Cannot instantiate non-existent class: finfo in
/home/michael/pecl/Fileinfo-0.2/test.php on line 16
Looking at php_fileinfo.h I see five functions:
PHP_MINFO_FUNCTION(fileinfo);
PHP_FUNCTION(finfo_open);
PHP_FUNCTION(finfo_close);
PHP_FUNCTION(finfo_set_flags);
PHP_FUNCTION(finfo_file);
PHP_FUNCTION(finfo_buffer);
When I try to call the finfo_file function, I get:
Warning: finfo_file() expects at least 2 parameters, 1 given in
/home/michael/pecl/Fileinfo-0.2/test.php on line 7
It would be nice if there were docs explaining why I need a second argument. Trying to guess just
results in errors like this:
Warning: finfo_file() expects at least 2 parameters, 1 given in
/home/michael/pecl/Fileinfo-0.2/test.php on line 7
Warning: finfo_open() expects parameter 1 to be long, string given in
/home/michael/pecl/Fileinfo-0.2/test.php on line 7
Compiling this extension (on Debian anyway) results in an error on libmagic, but it's lying.
You have to manually compile the file package (I used file-4.13). The latest Debian unstable package
is:
file 4.12-1 Determines file type using "magic" numbers
so I guess you either need 4.13 or Debian is missing a file-dev package.