Log in | Register | Lost password

Bottom
Media handler: how to get mime type?
  • Posted: 22.10.2007, 20:57
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    I have written a media handler that handles xls and doc. However, to display the documents appropriately (e.g. with an appropriate icon), the getMediaDisplayHtml() should know which mime type the media has. Is there some way (or some function) to find that out? Or do I have to create a separate media handler for each extension?
    Any help is appreciated.
  • Posted: 23.10.2007, 08:49
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    hi,

    check if mime_content_type function available on your server:
    http://www.php.net/manual/en/function.mime-content-type.php

    or Fileinfo PECL extension:
    http://www.php.net/manual/en/ref.fileinfo.php

    or use getID3 class:
    http://getid3.sourceforge.net/

    chaK!
  • Posted: 23.10.2007, 12:18
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Hi Chakal.
    Thank you for your reply. Indeed, that PECL extension seems exactly what I need, and I will use it if there is no better solution.
    A better solution could be if there were a function in Mediashare itself - that would be a lot faster because while Fileinfo would have to open the file to find out what it is, Mediashare already knows the mime type and probably stores it somewhere. But I don't know how if there is a Mediashare function that gives back the mime type.

Template courtesy of Designs By Darren.