Bug #57601 [Opn->Nab]: Fileinfo problem with magic files.

From: Date: Thu, 24 Nov 2016 14:57:17 +0000
Subject: Bug #57601 [Opn->Nab]: Fileinfo problem with magic files.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205608@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=57601&edit=1 ID: 57601 Updated by: ab@php.net Reported by: dario dot borreguero at gmail dot com Summary: Fileinfo problem with magic files. -Status: Open +Status: Not a bug Type: Bug -Package: Fileinfo +Package: *General Issues Operating System: Windows XP SP2 PHP Version: 5.2.1 Block user comment: N Private report: N New Comment: This is now in the core. Thanks. Previous Comments: ------------------------------------------------------------------------ [2007-03-30 09:38:24] dario dot borreguero at gmail dot com Description: ------------ After reading several bugs that were set to "Bogus". I believe they should be taken into account: http://pecl.php.net/bugs/bug.php?id=7391 http://pecl.php.net/bugs/bug.php?id=7555 http://pecl.php.net/bugs/bug.php?id=9166 I've installed this package as an extra, as a result my php.ini file has been modified, inserting the following lines: [PHP_FILEINFO] extension=php_fileinfo.dll After that, I've tried to get the MIME type from a file, using the following code: $finfo = finfo_open(FILEINFO_MIME); echo finfo_file($finfo, 'D:\Downloads\test.txt') . "\n"; finfo_close($finfo); But it has always returned the error: finfo_open()[function.finfo_open]: Failed to load magic database at '(null)'. After reading carefully the documentation I realised that it needs another parameter with the name of a magic database file. http://es2.php.net/manual/en/ref.fileinfo.php But I could not find any magic file. So I decided to install PECL package Mymetype. After that I got a magic.mime file in the folder c:\php\extras. I thought I could use that file with Fileinfo functions, so I modified the code: // Extension .mime is automatically added as it is told in // Bug #7555 and #7391. $finfo = finfo_open(FILEINFO_MIME, 'c:\php\extras\magic'); echo finfo_file($finfo, 'D:\Downloads\test.txt') . "\n"; finfo_close($finfo); but I always got the same result: application/x-dpkg As it is described in bug #9166, because of the problems with '!' characters. Then, I modified that magic database file escaping that characters (using backslashes) and it seemed to work. But there were a lot more special characters like those and others. For that reason I dived into that problem and I found more help at the comments added in http://es2.php.net/manual/en/function.finfo-open.php. I just downloaded the files at http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=18878 As it is said in the links of EvilPuppetMaster's comment. After extracting the files I found a magic.mime file. I used that file and it now works pretty fine!! In conclusion, Fileinfo PECL package installation should be modified in order to attach a magic.mime file, as it is done in Mimetype PECL package. Sorry for the length of my explanation, but I've tried to sum up everything I've done to resolve my problem and to keep it clear for future problems. Dario. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=57601&edit=1

« previous php.bugs (#205608) next »