Bug #67516 [Com]: wrong mimetypes with finfo_file(filename, FILEINFO_MIME_TYPE)

From: Date: Sun, 29 Jun 2014 14:57:45 +0000
Subject: Bug #67516 [Com]: wrong mimetypes with finfo_file(filename, FILEINFO_MIME_TYPE)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186374@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67516&edit=1

 ID:                 67516
 Comment by:         spam2 at rhsoft dot net
 Reported by:        spam2 at rhsoft dot net
 Summary:            wrong mimetypes with finfo_file(filename,
                     FILEINFO_MIME_TYPE)
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux
 PHP Version:        5.5.13
 Block user comment: N
 Private report:     N

 New Comment:

what i completly don't understand is why PHP obviously brings it's on mime-magic and
static implementation instead just use the operating systems file-libs


Previous Comments:
------------------------------------------------------------------------
[2014-06-25 17:00:19] spam2 at rhsoft dot net

Description:
------------
i have at least one GIF image with 2.3 MB which is detected as application/octet-stream while
'/usr/bin/file -b --mime-type' on the same machine correctly results in image/gif

sadly i don't see here any option to attach the image :-(
that makes it hard to implement relieable checks if the
extension of uploads matchs the expected mime-type

[harry@srv-rhsoft:~/Desktop]$ php mime.php 
/usr/bin/file -b --mime-type
image/gif

finfo_file(filename, FILEINFO_MIME_TYPE)
application/octet-stream


Test script:
---------------
#!/usr/bin/php
<?php
 echo '/usr/bin/file -b --mime-type' . "\n";
 passthru('/usr/bin/file -b --mime-type ' . escapeshellarg(__DIR__ . '/1.gif'));
 echo "\n";
 echo 'finfo_file(filename, FILEINFO_MIME_TYPE)' . "\n";
 $finfo_handle = finfo_open();
 echo finfo_file($finfo_handle, __DIR__ . '/1.gif', FILEINFO_MIME_TYPE) . "\n";
 finfo_close($finfo_handle);
?>

Expected result:
----------------
image/gif as result

Actual result:
--------------
application/octet-stream as result


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67516&edit=1


Thread (30 messages)

« previous php.bugs (#186374) next »