Mime Type functions not working
Posted by: SpiderSpartan (---.fuse.net)
Date: July 19, 2009 07:36AM

I'm trying to code an Index that will list the files in a directory with a specific icon next to them based on its mime type. However, I can't get any of the mime functions that I've found to work.

I tried "mime_content_type($filename)" from [us3.php.net]
That gave me the error "mime_content_type() undefined"

Then I tried
"$finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
echo finfo_file($finfo, $filename)"
from [us.php.net]

This gives me the error "finfo_open() undefined"

So what do I need to do to get the mime types of these files. like "text/html" or "audio/mpeg"?
Thanks for any help.

Options: ReplyQuote
Re: Mime Type functions not working
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: July 19, 2009 05:47PM

In order to use those functions you need to enable their respective extension.

So for the mine_content_type() function to work you need to configure PHP as per the instructions here: -> [uk.php.net]

For finfo_* functions to work you need to enable the extension called php_fileinfo. Left click wamp tray icon and select PHP > PHP Extensions > php_fileinfo

Options: ReplyQuote
Re: Mime Type functions not working
Posted by: SpiderSpartan (---.fuse.net)
Date: July 19, 2009 08:13PM

OK, I've tried a few things. First I enabled the "php_fileinfo" the "php_mime_magic" php extensions in wamp. I also enabled the "mime_module" and "mime_magic_module" for apache in wamp. I no longer get an error when using "mime_content_type()", but it returns an empty string.

I've tried setting mime_magic.magicfile = "$PHP_INSTALL_DIR\magic.mime" in the php.ini file.
replacing "$PHP_INSTALL_DIR" with
"C:\wamp\bin\php\php5.2.9-2\extras" and
"C:\wamp\bin\apache\Apache2.2.11\conf"

Any ideas what's going on here? Thanks again for the help.

Options: ReplyQuote
Re: Mime Type functions not working
Posted by: SpiderSpartan (161.155.15.---)
Date: July 21, 2009 02:51PM

looks like the problem might have been that I was running php 5.2. I upgraded to php 5.3 and things seem to be working. Thanks to the guys over at dreamincode.net

Options: ReplyQuote


Sorry, only registered users may post in this forum.