Jump to content

Archived

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

JustFoo

mime_magic file

Recommended Posts

Hello all,

I am attempting to use the mime_content_type('filename') function that comes in the mime_magic dll, I followed all instructions to set it up and edited the php.ini file and restarted the server and this morning it worked 2 times then just stopped working for some reason.  The script i had running doesnt show the mimetype of files anymore. 

Script:
$file = "\\pathToFile\\php.gif";
echo mime_content_type($file);

php.ini:
extension=php_mime_magic.dll
[mime_magic]
mime_magic.debug = on
mime_magic.magicfile = "c:\PHP\extras\magic.mime"

thanks for any help
JustFoo

Share this post


Link to post
Share on other sites
Try putting [code]ini_set('display_errors',true);
error_reporting(E_ALL);[/code] in the top of the script and see if any errors are returned.

Share this post


Link to post
Share on other sites
Warning: mime_content_type() [http://www.php.net/mime_magic]: mime_magic not initialized in

C:\path to script\test.php on line 6

line 6 is echo  mime_content_type($file);

mime_magic shows up if i do like phpinfo();

Share this post


Link to post
Share on other sites
Did you set the correct path? Try replacing the backslashes with forward slashes and see if it helps.

Share this post


Link to post
Share on other sites
same exact error idk why but a little while ago it worked fine the way i had the script it returned image/gif and then i tried a different file and it returned that mime type then when i tried a third file it just stopped printing out the type and then i did a is_function(mime_content_type) and it told me that its not a function and now im here...

Share this post


Link to post
Share on other sites
Attach the magic.mime so we can see if it's a correct file (click on 'Additional Options...' when posting).

Share this post


Link to post
Share on other sites
Should be the correct file. I have no idea why this don't work.

Share this post


Link to post
Share on other sites
now it says on my phpinfo page 

mime_magic support invalid magic file, disabled

Directive Local Value Master Value
mime_magic.debug On On
mime_magic.magicfile c:\PHP\extras\magic.mime c:\PHP\extras\magic.mime

Share this post


Link to post
Share on other sites
Try [url=http://www.google.com/search?q=magic.mime]searching on Google for 'magic.mime'[/url].

Share this post


Link to post
Share on other sites
i redownloaded php and took the mime file from that and it still didn't work.  Any other ideas????

thanks for the help

Share this post


Link to post
Share on other sites
i restarted the web server and again the function worked fine then all of a sudden just stopped working again...is there any other way to figure out the type of a file not based on the file extension alone???

Share this post


Link to post
Share on other sites

×

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.