note 79063 added to ref.fileinfo
| From: | Paul at osu1 dot php dot net | Date: | Thu, 08 Nov 2007 16:12:23 +0000 |
| Subject: | note 79063 added to ref.fileinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132117@lists.php.net to get a copy of this message | ||
The results of this function seem to be of dubious quality.
eg
1) a Word doc returns:
'application/msword application/msword'
...ok not too bad, but why does it come back twice?
2) a PHP file comes back as:
'text/x-c++; charset=us-ascii'
My test file started with '<?php' so not ambiguous really. And where does it get the
charset assumption from?
3) a text doc that starts with the letters 'GIF' comes back as:
'image/gif'
(just like in DanielWalker's example for the unix 'file' command)
I had better results using the PEAR 'MIME_Type' package. It gave proper answers for 1
& 3 and identified the PHP file as 'text/plain' which is probably better than a false
match for C++
Both finfo_file and MIME_Type correctly identified my other two test files which were a windows exe
renamed with .doc extension, and a PDF also renamed with .doc extension.
----
Server IP: 87.124.64.96
Probable Submitter: 82.34.219.95
----
Manual Page -- http://www.php.net/manual/en/ref.fileinfo.php
Edit -- https://master.php.net/note/edit/79063
Del: integrated -- https://master.php.net/note/delete/79063/integrated
Del: useless -- https://master.php.net/note/delete/79063/useless
Del: bad code -- https://master.php.net/note/delete/79063/bad+code
Del: spam -- https://master.php.net/note/delete/79063/spam
Del: non-english -- https://master.php.net/note/delete/79063/non-english
Del: in docs -- https://master.php.net/note/delete/79063/in+docs
Del: other reasons-- https://master.php.net/note/delete/79063
Reject -- https://master.php.net/note/reject/79063
Search -- https://master.php.net/manage/user-notes.php