You are here

README.txt in MimeDetect 6

Same filename and directory in other branches
  1. 8 README.txt
  2. 5 README.txt
  3. 7 README.txt
Background
===============
MimeDetect strives to provide consistent and accurate server side MIME type
detection. It supports the PHP FileInfo Extension, the UNIX 'file' command,
then tries to use the MIME type supplied with the file object. If everything
fails it will select a MIME type based on file extension.

Troubleshooting
===============
MimeDetect is distributed with a Magic database file to make FileInfo based
MIME detection more consistent across servers. This database file may not
work with your server. When this happens, you may see an error message like
this in your Drupal status report:

  Fileinfo could not load the magic file. It could be corrupted. Try
  reinstalling the magic file distributed with the MimeDetect module.
  (Currently using Mime type detection PHP Fileinfo Extension)

This message means that the included 'magic' database file will not work with
your server configuration and may have to use a different 'magic' file.
Usually there is a 'magic' file included in the File 4.x distribution, a PHP
extension installed on your server.

The first step to troubleshooting this problem is to determine if the extension
is installed on your server, and then to learn the path to the 'magic' file.
You can contact your web host for this. Then, in your settings.php, you can
define a new variable that tells Mimedetect the correct and absolute path of
the file to use:

  $conf = array(
    'mimedetect_magic' => '/usr/share/file/magic',
  );

The path '/usr/share/file/' is a common location for this file but you may have
to replace that path with the correct magic file path if it is different on
your server. Some configurations will require you to use a file extension on
the file name, such as '/usr/share/file/magic.mime'.

If this error message persists then you can create a PHP script to test that
you have the correct path to the 'magic' database file. Create a simple text
file named test.php in your web root and call it in a browser.  Use this
snippet in your script:

<?php
  $magic_file = '/usr/share/file/magic';
  $finfo = finfo_open(FILEINFO_MIME, $magic_file);
  if (!$finfo) {
    echo "Opening fileinfo database failed";
    exit();
  }
?>

Again, as mentioned above, the path will need to reflect the correct magic file
path and you may need to add .mime to the file name.

File

README.txt
View source
  1. Background
  2. ===============
  3. MimeDetect strives to provide consistent and accurate server side MIME type
  4. detection. It supports the PHP FileInfo Extension, the UNIX 'file' command,
  5. then tries to use the MIME type supplied with the file object. If everything
  6. fails it will select a MIME type based on file extension.
  7. Troubleshooting
  8. ===============
  9. MimeDetect is distributed with a Magic database file to make FileInfo based
  10. MIME detection more consistent across servers. This database file may not
  11. work with your server. When this happens, you may see an error message like
  12. this in your Drupal status report:
  13. Fileinfo could not load the magic file. It could be corrupted. Try
  14. reinstalling the magic file distributed with the MimeDetect module.
  15. (Currently using Mime type detection PHP Fileinfo Extension)
  16. This message means that the included 'magic' database file will not work with
  17. your server configuration and may have to use a different 'magic' file.
  18. Usually there is a 'magic' file included in the File 4.x distribution, a PHP
  19. extension installed on your server.
  20. The first step to troubleshooting this problem is to determine if the extension
  21. is installed on your server, and then to learn the path to the 'magic' file.
  22. You can contact your web host for this. Then, in your settings.php, you can
  23. define a new variable that tells Mimedetect the correct and absolute path of
  24. the file to use:
  25. $conf = array(
  26. 'mimedetect_magic' => '/usr/share/file/magic',
  27. );
  28. The path '/usr/share/file/' is a common location for this file but you may have
  29. to replace that path with the correct magic file path if it is different on
  30. your server. Some configurations will require you to use a file extension on
  31. the file name, such as '/usr/share/file/magic.mime'.
  32. If this error message persists then you can create a PHP script to test that
  33. you have the correct path to the 'magic' database file. Create a simple text
  34. file named test.php in your web root and call it in a browser. Use this
  35. snippet in your script:
  36. $magic_file = '/usr/share/file/magic';
  37. $finfo = finfo_open(FILEINFO_MIME, $magic_file);
  38. if (!$finfo) {
  39. echo "Opening fileinfo database failed";
  40. exit();
  41. }
  42. ?>
  43. Again, as mentioned above, the path will need to reflect the correct magic file
  44. path and you may need to add .mime to the file name.