note 73153 deleted from function.finfo-file by mazzanet

From: Date: Sun, 11 Feb 2007 08:12:56 +0000
Subject: note 73153 deleted from function.finfo-file by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123236@lists.php.net to get a copy of this message
Note Submitter: d dot baourdos at hotmail dot com Reason: useless ---- System: Windows XP sp2 Apache HTTPd 2.2.x PHP (from zip) 5.2.x ------------------------------------------------------------ trying to make finfo to work returned errors 'mime_magic not initialized' and another error about not being able to load magic db. I managed to replace mime_content_type() with fileinfo in my script in about 2 mins AFTER i managed to make the func work. 1) download php_fileinfo.dll from http://pecl4win.php.net/list.php and place it in the ext folder of your PHP installation. mine is F:\php-5.2.1\ext. php.ini file should contain extension_dir = "F:\php-5.2.1\ext" 2) edit php.ini and add extension=php_fileinfo.dll [mime_magic] mime_magic.debug = On mime_magic.magicfile = "F:/php-5.2.1/magic.mime" for some reason it will not work again but a small fix can be used while creating the fileinfo object. 3) restart apache2 service (start -> run -> net stop apache2 && net start apache2). ---------------------------------------------------------- inside the php file: (this is a copy from my file) // this will load the filetypes -- fixed the null db error $fi = new finfo(FILEINFO_MIME,"F:/php-5.2.1/magic"); /* * $type = mime_content_type($this->dir."/".$Files[$i]); * removed - decperated */ $type = $fi->buffer(file_get_contents($this->dir."/".$Files[$i])); ---------------------------------------------------------- you may also notice that it always returns the same type for every file. up to now i havent found something else xcept go through the magic file and delete all the lines that have ! and <arch> in the second column. for example: 0 beshort 0xffd8 image/jpeg 0 string #!/usr/local/bin/ae text/script ^^ those cause no prob 0 string <arch>\n__________E application/x-ar 0 string !<arch>\n________64E application/data ^^ those two and similar must be deleted * * for any comments or corrections please email me on the email specified above

« previous php.notes (#123236) next »