Link to home
Start Free TrialLog in
Avatar of Jason Livengood
Jason LivengoodFlag for United States of America

asked on

PHP Function Call to undefined function mime_content_type()

I have a php app that I have that downloads files (.pdf's) from a server and people view them through a web browser. Right now when the user goes to view a file on downloading the page blows up with the following error:

Fatal error: Call to undefined function mime_content_type() in E:\xampp\htdocs\document_management\download.php on line 56

line 56 looks like this:
header('Content-type: '.mime_content_type($downloadFilePath));


I have checked and the server is looking for a valid document so its not the $downloadFilePath variable thats causing the issue per say. I read somewhere that i need to enable a Magic.mime dll of some sort in my php.ini file. So in that file I see this:

[mime_magic]
mime_magic.magicfile = "E:\xampp\php\extras\magic.mime"
;mime_magic.debug = On


but when I go to the file path listed here there is nothing that jumps out as related to a dll of this sort of name. is this something I need to install and configure to make the error go away? How do I make this error go away. I am mostly a .net guy so any advice or help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of termlimit
termlimit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason Livengood

ASKER

I have put the magic mime file in place. the php config file now points to it. However the function call still blows up.

In the link to the manual above its states the following:

"You must compile PHP with the configure switch --with-mime-magic to get support for mime-type functions. The extension needs a copy of the simplified magic file that is distributed with the Apache httpd."

How do configure this switch and recompile php with the switch configured ?  Any help or  direction would be greatly appreciated.

Did you try the script I posted at ID:36039723?  I think the use of mime_content_type() is not necessary and since it appears to be getting in your way you might want to try removing that stumbling block.
I simply replaced :
header('Content-type: '.mime_content_type($downloadFilePath));

with this
header("Content-Type: application-x/force-download");

Issue seems to have gone away now. Thank you for your advice and help.