FAQ
I'm planning on adding some MIME type to the CLI web server.

For PHP 5.5.5 CLI web server I added the .pdf MIME type. I was using
the webserver for a conference exhibition hall demo and needed to
present a PDF.

Some other multi-media types could be useful in future situations, and
in general. I'm thinking of adding these to PHP 5.5.6 & master:

         { "avi", "video/x-msvideo" },
         { "flv", "video/x-flv" },
         { "swf", "application/x-shockwave-flash" },
         { "qt", "video/quicktime" },
         { "mov", "video/quicktime" },
         { "mp3", "audio/mpeg" },
         { "mp4", "video/mpeg" },
         { "mpg", "video/mpeg" },
         { "mpeg", "video/mpeg" },
         { "wav", "audio/wav" },

Notes:

- A router can be used to add to, or override, the MIME type lookups,
    see http://php.net/manual/en/features.commandline.webserver.php

- The web server code does a linear lookup through the MIME table,
    defaulting on failure to returning "application/octet-stream".

Search Discussions

  • Dan Ackroyd at Oct 26, 2013 at 5:39 pm
    Hi,

    Christopher Jones wrote:
    I'm thinking of adding these to PHP 5.5.6 & master:
    { "mp4", "video/mpeg" },
    FYI that's not the correct mime type for mp4 -
    http://www.rfc-editor.org/rfc/rfc4337.txt

    The exact mime type depends on the content of the file, but
    'video/mp4' would be more appropriate than 'video/mpeg'.

    cheers
    Dan

    On Fri, Oct 25, 2013 at 7:55 PM, Christopher Jones
    wrote:
    I'm planning on adding some MIME type to the CLI web server.

    For PHP 5.5.5 CLI web server I added the .pdf MIME type. I was using
    the webserver for a conference exhibition hall demo and needed to
    present a PDF.

    Some other multi-media types could be useful in future situations, and
    in general. I'm thinking of adding these to PHP 5.5.6 & master:

    { "avi", "video/x-msvideo" },
    { "flv", "video/x-flv" },
    { "swf", "application/x-shockwave-flash" },
    { "qt", "video/quicktime" },
    { "mov", "video/quicktime" },
    { "mp3", "audio/mpeg" },
    { "mp4", "video/mpeg" },
    { "mpg", "video/mpeg" },
    { "mpeg", "video/mpeg" },
    { "wav", "audio/wav" },

    Notes:

    - A router can be used to add to, or override, the MIME type lookups,
    see http://php.net/manual/en/features.commandline.webserver.php

    - The web server code does a linear lookup through the MIME table,
    defaulting on failure to returning "application/octet-stream".

    --
    christopher.jones@oracle.com http://twitter.com/ghrd
    Free PHP & Oracle book:
    http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Christopher Jones at Oct 26, 2013 at 10:57 pm

    On 10/26/13 10:39 AM, Dan Ackroyd wrote:
    Hi,

    Christopher Jones wrote:
    I'm thinking of adding these to PHP 5.5.6 & master:
    { "mp4", "video/mpeg" },
    FYI that's not the correct mime type for mp4 -
    http://www.rfc-editor.org/rfc/rfc4337.txt

    The exact mime type depends on the content of the file, but
    'video/mp4' would be more appropriate than 'video/mpeg'.
    My mistake. Thanks for picking it up.

    Chris
    cheers
    Dan

    On Fri, Oct 25, 2013 at 7:55 PM, Christopher Jones
    wrote:
    I'm planning on adding some MIME type to the CLI web server.

    For PHP 5.5.5 CLI web server I added the .pdf MIME type. I was using
    the webserver for a conference exhibition hall demo and needed to
    present a PDF.

    Some other multi-media types could be useful in future situations, and
    in general. I'm thinking of adding these to PHP 5.5.6 & master:

    { "avi", "video/x-msvideo" },
    { "flv", "video/x-flv" },
    { "swf", "application/x-shockwave-flash" },
    { "qt", "video/quicktime" },
    { "mov", "video/quicktime" },
    { "mp3", "audio/mpeg" },
    { "mp4", "video/mpeg" },
    { "mpg", "video/mpeg" },
    { "mpeg", "video/mpeg" },
    { "wav", "audio/wav" },

    Notes:

    - A router can be used to add to, or override, the MIME type lookups,
    see http://php.net/manual/en/features.commandline.webserver.php

    - The web server code does a linear lookup through the MIME table,
    defaulting on failure to returning "application/octet-stream".

    --
    christopher.jones@oracle.com http://twitter.com/ghrd
    Free PHP & Oracle book:
    http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    christopher.jones@oracle.com http://twitter.com/ghrd
    Free PHP & Oracle book:
    http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
  • Christopher Jones at Oct 31, 2013 at 9:01 pm

    On 10/25/2013 12:55 PM, Christopher Jones wrote:
    I'm planning on adding some MIME type to the CLI web server.

    For PHP 5.5.5 CLI web server I added the .pdf MIME type. I was using
    the webserver for a conference exhibition hall demo and needed to
    present a PDF.

    Some other multi-media types could be useful in future situations, and
    in general. I'm thinking of adding these to PHP 5.5.6 & master:

    { "avi", "video/x-msvideo" },
    { "flv", "video/x-flv" },
    { "swf", "application/x-shockwave-flash" },
    { "qt", "video/quicktime" },
    { "mov", "video/quicktime" },
    { "mp3", "audio/mpeg" },
    { "mp4", "video/mpeg" },
    { "mpg", "video/mpeg" },
    { "mpeg", "video/mpeg" },
    { "wav", "audio/wav" },

    Notes:

    - A router can be used to add to, or override, the MIME type lookups,
    see http://php.net/manual/en/features.commandline.webserver.php

    - The web server code does a linear lookup through the MIME table,
    defaulting on failure to returning "application/octet-stream".
    I had feedback from one person who suggested adding these:

              { "3gp", "video/3gpp" }, //This is standard video format used for MMS in phones
              { "apk", "application/vnd.android.package-archive" },
              { "avi", "video/x-msvideo" },
              { "bmp", "image/x-ms-bmp" },
              { "csv", "text/comma-separated-values" },
              { "doc", "application/msword" },
              { "docx", "application/msword" },
              { "flac", "audio/flac" },
              { "gz", "application/x-gzip" },
              { "gzip", "application/x-gzip" },
              { "ics", "text/calendar" },
              { "kml", "application/vnd.google-earth.kml+xml" },
              { "kmz", "application/vnd.google-earth.kmz" },
              { "m4a", "audio/mp4" },
              { "mp3", "audio/mpeg" },
              { "mp4", "video/mp4" },
              { "mpg", "video/mpeg" },
              { "mpeg", "video/mpeg" },
              { "mov", "video/quicktime" },
              { "odp", "application/vnd.oasis.opendocument.presentation" },
              { "ods", "application/vnd.oasis.opendocument.spreadsheet" },
              { "odt", "application/vnd.oasis.opendocument.text" },
              { "oga", "audio/ogg" },
              { "pdf", "application/pdf" },
              { "pptx", "application/vnd.ms-powerpoint" },
              { "pps", "application/vnd.ms-powerpoint" },
              { "qt", "video/quicktime" },
              { "swf", "application/x-shockwave-flash" },
              { "tar", "application/x-tar" },
              { "text", "text/plain" },
              { "tif", "image/tiff" },
              { "wav", "audio/wav" },
              { "wmv", "video/x-ms-wmv" },
              { "xls", "application/vnd.ms-excel" },
              { "xlsx", "application/vnd.ms-excel" },
              { "zip", "application/x-zip-compressed"


    The PHP CLI web server 5.5 currrently supports these MIME types natively:

      { "html", "text/html" },
      { "htm", "text/html" },
      { "js", "text/javascript" },
      { "css", "text/css" },
      { "gif", "image/gif" },
      { "jpg", "image/jpeg" },
      { "jpeg", "image/jpeg" },
      { "jpe", "image/jpeg" },
      { "png", "image/png" },
      { "svg", "image/svg+xml" },
      { "txt", "text/plain" },
      { "webm", "video/webm" },
      { "ogv", "video/ogg" },
      { "ogg", "audio/ogg" },


    Final comments anyone, before I commit next week?

    Chris
  • Derick Rethans at Oct 31, 2013 at 9:32 pm

    On Thu, 31 Oct 2013, Christopher Jones wrote:

    The PHP CLI web server 5.5 currrently supports these MIME types
    natively:

    { "html", "text/html" },
    { "htm", "text/html" },
    { "js", "text/javascript" },
    { "css", "text/css" },
    { "gif", "image/gif" },
    { "jpg", "image/jpeg" },
    { "jpeg", "image/jpeg" },
    { "jpe", "image/jpeg" },
    { "png", "image/png" },
    { "svg", "image/svg+xml" },
    { "txt", "text/plain" },
    { "webm", "video/webm" },
    { "ogv", "video/ogg" },
    { "ogg", "audio/ogg" },


    Final comments anyone, before I commit next week?
    Isn't there a reason why you can't use the fileinfo extension/code for
    this instead? Hardcoding it seems rather strange?

    cheers,
    Derick

    --
    http://derickrethans.nl | http://xdebug.org
    Like Xdebug? Consider a donation: http://xdebug.org/donate.php
    twitter: @derickr and @xdebug
    Posted with an email client that doesn't mangle email: alpine
  • Andrea Faulds at Oct 31, 2013 at 9:37 pm

    On 31/10/13 21:32, Derick Rethans wrote:
    Isn't there a reason why you can't use the fileinfo extension/code for
    this instead? Hardcoding it seems rather strange?
    I looked at the manual and mime_content_type() is deprecated and tells
    me to use the Fileinfo PECL extension. From which I am led back to the
    parent section, which is for the built-in Fileinfo extension. Looks like
    the manual is out-of-date.

    Anyhow, looks like finfo_file() works as we'd want, though I feel uneasy
    about guessing filetypes this way. Perhaps we should have several
    explicitly specified ones (.txt as text/plain, .html as text/html,
    etc.), and guess the rest? Especially for ones which it would not
    correctly guess.

    Thanks.
    --
    Andrea Faulds
    http://ajf.me/
  • Stas Malyshev at Oct 31, 2013 at 11:12 pm
    Hi!
    Final comments anyone, before I commit next week?
    It looks strange that we have to hardcode so many mimetypes in the code,
    and doesn't sound a scalable solution. Can't we make it use data from
    fileinfo or some other customizeable table so we don't have to keep all
    MIME types hardcoded in the code? Maybe some ability to use Apache's
    mime.types file?
    --
    Stanislav Malyshev, Software Architect
    SugarCRM: http://www.sugarcrm.com/
    (408)454-6900 ext. 227
  • Christopher Jones at Oct 31, 2013 at 11:51 pm

    On 10/31/13 4:12 PM, Stas Malyshev wrote:
    Hi!
    Final comments anyone, before I commit next week?
    It looks strange that we have to hardcode so many mimetypes in the code,
    and doesn't sound a scalable solution. Can't we make it use data from
    fileinfo or some other customizeable table so we don't have to keep all
    MIME types hardcoded in the code? Maybe some ability to use Apache's
    mime.types file?
    It isn't scalable, but users can always use a router script to add
    additional types so there isn't a real world problem in missing
    uncommon extensions.

    My idea was to add common extensions to the existing look-up list. A
    quick and straight-forward solution to making the CLI web-server
    handle the 80-20 rule.

    If someone (ajf?) wants to work on a more comprehensive solution
    instead, I have no objection.

    Chris
  • Mike Willbanks at Nov 23, 2013 at 4:22 am
    Chris,

    What is wrong with a more common magic file which fileinfo utilizes? I
    understand the concept of adding common extensions but only as a fallback
    to distro behavior.

    Regards,

    Mike
    On Oct 31, 2013 6:52 PM, "Christopher Jones" wrote:


    On 10/31/13 4:12 PM, Stas Malyshev wrote:

    Hi!

    Final comments anyone, before I commit next week?
    It looks strange that we have to hardcode so many mimetypes in the code,
    and doesn't sound a scalable solution. Can't we make it use data from
    fileinfo or some other customizeable table so we don't have to keep all
    MIME types hardcoded in the code? Maybe some ability to use Apache's
    mime.types file?
    It isn't scalable, but users can always use a router script to add
    additional types so there isn't a real world problem in missing
    uncommon extensions.

    My idea was to add common extensions to the existing look-up list. A
    quick and straight-forward solution to making the CLI web-server
    handle the 80-20 rule.

    If someone (ajf?) wants to work on a more comprehensive solution
    instead, I have no objection.

    Chris

    --
    christopher.jones@oracle.com http://twitter.com/ghrd
    Free PHP & Oracle book:
    http://www.oracle.com/technetwork/topics/php/
    underground-php-oracle-manual-098250.html

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Christopher Jones at Nov 23, 2013 at 4:39 am

    On 11/22/13 8:22 PM, Mike Willbanks wrote:
    Chris,

    What is wrong with a more common magic file which fileinfo utilizes? I
    understand the concept of adding common extensions but only as a fallback
    to distro behavior.

    Regards,

    Mike
    There's nothing wrong that I know of. If you have time to implement it,
    go ahead.

    Chris
  • Pierre Joye at Nov 23, 2013 at 9:07 am
    hi,

    On Sat, Nov 23, 2013 at 5:39 AM, Christopher Jones
    wrote:
    On 11/22/13 8:22 PM, Mike Willbanks wrote:

    Chris,

    What is wrong with a more common magic file which fileinfo utilizes? I
    understand the concept of adding common extensions but only as a fallback
    to distro behavior.

    Regards,

    Mike

    There's nothing wrong that I know of. If you have time to implement it,
    go ahead.
    There is nothing wrong but it may not as easy as it looks.

    This file must be available when fiinfo is not enabled (build time) or
    loaded. fileinfo ma be shared too (as far as I remember almost all
    distros provide it optionally and shared). That's something to keep in
    mind while implementing a patch.

    Cheers,
    --
    Pierre

    @pierrejoye | http://www.libgd.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedOct 25, '13 at 7:55p
activeNov 23, '13 at 9:07a
posts11
users7
websitephp.net

People

Translate

site design / logo © 2022 Grokbase