Jump to content

Get MIME type of file.


hellonoko

Recommended Posts

My script for returning the mime type of a file does not seem to work:

 

$handle = finfo_open(FILEINFO_MIME);
echo $mime_type = finfo_file($handle,$file_name);
exit();

 

Errors:

Warning: finfo_open() [function.finfo-open]: Failed to load magic database at '(null)'. in C:\www\idea\imagebox\add_image.php on line 147

Warning: finfo_file(): supplied argument is not a valid file_info resource in C:\www\idea\imagebox\add_image.php on line 148

 

I did have to turn on php_fileinfo in WAMP for this.

Is there something else I need to turn on?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/82903-get-mime-type-of-file/
Share on other sites

The page in the php manual states how to specify the parameter in the function call so that the magic.mime file can be found -

magic_file

Name of a magic database file, usually something like /path/to/magic.mime. If not specified, the MAGIC environment variable is used. If this variable is not set either, /usr/share/misc/magic is used by default. A .mime and/or .mgc suffix is added if needed.

 

The magic.mime file is typically located in the "extras" folder inside the php folder.

Link to comment
https://forums.phpfreaks.com/topic/82903-get-mime-type-of-file/#findComment-421738
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.