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.

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.

 

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.