Finding MIME type
Posted: Thu Jan 29, 2009 3:17 pm
Hi!
I am trying to find the MIME type of a file, but the results I am getting are quite confusing. I am running Ubuntu 8.04.
The file with which I am testing is an OpenOffice writer file. My code is as follows:
This outputs "application/x-zip" which is clearly wrong or at least useless. If I, however, do a mimetype command in the console, the correct result is shown:
Running mimetype in debug mode, reveals the magic file used:
Trying now to let finfo use that magic file, however, returns an error:
Outputs:
Warning: finfo_open(): Failed to load magic database at '/usr/share/mime/magic'.
Has anyone run across this error before?
Yours sincerely
Rasmus
I am trying to find the MIME type of a file, but the results I am getting are quite confusing. I am running Ubuntu 8.04.
The file with which I am testing is an OpenOffice writer file. My code is as follows:
Code: Select all
$handle = finfo_open(FILEINFO_MIME);
print(finfo_file($handle,$filename) . "\n");
Code: Select all
application/vnd.oasis.opendocument.textCode: Select all
Hashing magic from /usr/share/mime/magicCode: Select all
$handle = finfo_open(FILEINFO_MIME, '/usr/share/mime/magic');Warning: finfo_open(): Failed to load magic database at '/usr/share/mime/magic'.
Has anyone run across this error before?
Yours sincerely
Rasmus