note 50834 added to ref.mime-magic
| From: | phpsite at michael dot mailshell dot com | Date: | Fri, 11 Mar 2005 05:42:21 +0000 |
| Subject: | note 50834 added to ref.mime-magic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86234@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/ref.mime-magic.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50834
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50834&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50834&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50834&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50834&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50834&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50834&report=yes
Search -- http://master.php.net/manage/user-notes.php