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

From: Date: Fri, 04 Jul 2014 13:53:04 +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-186470@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: fayez at bem981 dot cu dot cc 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: i tried this example with gif image size:8.2m and i get this result: /usr/bin/file -b --mime-type image/gif finfo_file(filename, FILEINFO_MIME_TYPE) image/gif it's work Previous Comments: ------------------------------------------------------------------------ [2014-06-29 14:57:44] spam2 at rhsoft dot net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#186470) next »