note 73153 added to function.finfo-file
| From: | d dot baourdos at hotmail dot com | Date: | Sun, 11 Feb 2007 06:55:08 +0000 |
| Subject: | note 73153 added to function.finfo-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123233@lists.php.net to get a copy of this message | ||
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
----
Server IP: 83.138.144.80
Probable Submitter: 82.3.194.96
----
Manual Page -- http://www.php.net/manual/en/function.finfo-file.php
Edit -- https://master.php.net/note/edit/73153
Del: integrated -- https://master.php.net/note/delete/73153/integrated
Del: useless -- https://master.php.net/note/delete/73153/useless
Del: bad code -- https://master.php.net/note/delete/73153/bad+code
Del: spam -- https://master.php.net/note/delete/73153/spam
Del: non-english -- https://master.php.net/note/delete/73153/non-english
Del: in docs -- https://master.php.net/note/delete/73153/in+docs
Del: other reasons-- https://master.php.net/note/delete/73153
Reject -- https://master.php.net/note/reject/73153
Search -- https://master.php.net/manage/user-notes.php