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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.