Jump to content


Photo

mime_magic file


  • Please log in to reply
13 replies to this topic

#1 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 02:01 PM

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



#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:03 PM

Try putting
ini_set('display_errors',true);
error_reporting(E_ALL);
in the top of the script and see if any errors are returned.

#3 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 02:08 PM

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();

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:13 PM

Did you set the correct path? Try replacing the backslashes with forward slashes and see if it helps.

#5 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 02:22 PM

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...



#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:25 PM

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

#7 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 02:30 PM

magic.mime

[attachment deleted by admin]

#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:53 PM

Should be the correct file. I have no idea why this don't work.

#9 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 03:08 PM

why would it say its not initialized??

#10 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 03:09 PM

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


#11 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 03:19 PM

anyway i can get a new mime.magic file or something??

#12 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 03:47 PM

Try searching on Google for 'magic.mime'.

#13 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 03:59 PM

i redownloaded php and took the mime file from that and it still didn't work.  Any other ideas????

thanks for the help


#14 JustFoo

JustFoo
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 05:32 PM

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???




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users