Jump to content

Alternatives to Mime_content_type and Fileinfo


Jerzxu

Recommended Posts

Hello and Good Morning, so here's my question.

Basically, I need an alternative to mime_content_type and fileinfo.

 

Reason behind Fileinfo is becuase for some reason I can't get it to work whatsoever, and it's installed on my webserver (Host installed it). It says: Fatal error: Call to undefined function finfo_open(). I asked a fellow PHP programmer and she said that it sounds like they didn't install it. They reinstalled it and it's still the same.

 

As for the mime_content_type, which works well, except it only returns the mimes .jpg, and .gif, meaning that .png, .zip, .rar etc. get put out as text/plain which is bad. Becuase I am trying to limit the mime types to certain ones.

 

So basically if theres a fix for either of these or an alternative to those it would be helpful to have.

Link to comment
Share on other sites

i was looking at php.com and i found this

<?php
$finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension

if (!$finfo) {
    echo "Opening fileinfo database failed";
    exit();
}

/* get mime-type for a specific file */
$filename = "/usr/local/something.txt";
echo $finfo->file($filename);

/* close connection */
$finfo->close();
?>

 

try it and see if you get mine types or a error and what error do you get

 

Scott.

 

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.