Upload file types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shelly

    Upload file types

    I have upload working and the file type test has "audio/mid". I would also
    like allow other types, say .wav for example. Is it simply a case of
    changing:

    if ($_FILES['filename']['type'] == "audio/mid") {

    to

    if (($_FILES['filename']['type'] == "audio/mid") ||
    ($_FILES['filename']['type'] == "audio/wav") ) {

    Is there a more compact way of doing it?

    Also, please help me understand the meaning of "audio/mid". Why is there
    the prequalifier of "audio/" and not simply have "mid"? I am sure this is
    **somewhere** in the manual, but I haven't located it as yet.

    Shelly


  • Gordon Burditt

    #2
    Re: Upload file types

    >I have upload working and the file type test has "audio/mid". I would also

    This is a MIME type. You can do any test you want on it.
    [color=blue]
    >like allow other types, say .wav for example. Is it simply a case of
    >changing:
    >
    > if ($_FILES['filename']['type'] == "audio/mid") {
    >
    >to
    >
    > if (($_FILES['filename']['type'] == "audio/mid") ||
    > ($_FILES['filename']['type'] == "audio/wav") ) {
    >
    >Is there a more compact way of doing it?
    >
    >Also, please help me understand the meaning of "audio/mid". Why is there
    >the prequalifier of "audio/" and not simply have "mid"? I am sure this is
    >**somewhere* * in the manual, but I haven't located it as yet.[/color]

    MIME types have a general class (text, audio, video, etc.) and a
    specific format. It is common that something checking the type
    is interested in the class but is not particular about the type.
    This is particularly true for software that is not necessarily
    updated every time someone comes up with a new type.

    For example, a browser might send anything of class "audio" or
    "video" to the application "mplayer", and let IT worry about whether
    it can handle the specific type. Or it might handle a few specific
    types that it knows about, e.g. audio/aac, with specific programs,
    and let "mplayer" handle the remaining ones matching audio/* or
    video/* .

    Gordon L. Burditt

    Comment

    • John Dunlop

      #3
      Re: Upload file types

      Shelly wrote:
      [color=blue]
      > Also, please help me understand the meaning of "audio/mid".[/color]

      its meaning depends on its context. it has the *form* of a
      media type, as defined by MIME, but it's an error if it occurs
      anywhere a media type is expected, because it hasn't been
      registered and doesn't take the form of a private type.

      [the rest assumes it is registered]
      [color=blue]
      > Why is there the prequalifier of "audio/" and not simply have "mid"?[/color]

      <audio> (</> is just a separator, without any semantics) is
      what's termed a Top-Level Media Type, and usually indicates
      the general type of data, whereas <mid> is a Subtype of the
      specified top-level one, and usually indicates a specific
      format. so <mid> is a 'kind of' <audio>, if you like.

      --
      Jock

      Comment

      • Shelly

        #4
        Re: Upload file types

        Thank you very much. That was very educational. I will change mine to
        audio/*.

        Shelly

        "Gordon Burditt" <gordonb.7s0xu@ burditt.org> wrote in message
        news:11cjcorcam abnf6@corp.supe rnews.com...[color=blue][color=green]
        > >I have upload working and the file type test has "audio/mid". I would
        > >also[/color]
        >
        > This is a MIME type. You can do any test you want on it.
        >[color=green]
        >>like allow other types, say .wav for example. Is it simply a case of
        >>changing:
        >>
        >> if ($_FILES['filename']['type'] == "audio/mid") {
        >>
        >>to
        >>
        >> if (($_FILES['filename']['type'] == "audio/mid") ||
        >> ($_FILES['filename']['type'] == "audio/wav") ) {
        >>
        >>Is there a more compact way of doing it?
        >>
        >>Also, please help me understand the meaning of "audio/mid". Why is
        >>there
        >>the prequalifier of "audio/" and not simply have "mid"? I am sure this is
        >>**somewhere ** in the manual, but I haven't located it as yet.[/color]
        >
        > MIME types have a general class (text, audio, video, etc.) and a
        > specific format. It is common that something checking the type
        > is interested in the class but is not particular about the type.
        > This is particularly true for software that is not necessarily
        > updated every time someone comes up with a new type.
        >
        > For example, a browser might send anything of class "audio" or
        > "video" to the application "mplayer", and let IT worry about whether
        > it can handle the specific type. Or it might handle a few specific
        > types that it knows about, e.g. audio/aac, with specific programs,
        > and let "mplayer" handle the remaining ones matching audio/* or
        > video/* .
        >
        > Gordon L. Burditt
        >[/color]


        Comment

        • Gordon Burditt

          #5
          Re: Upload file types

          >Thank you very much. That was very educational. I will change mine to[color=blue]
          >audio/*.[/color]

          If you intend matching the type against "audio/*", you can't
          use a string comparison for that. You could extract the
          part before the / and compare it against "audio". Or you
          could use a regex pattern match (against, say, "^audio/.*$").

          You need to consider whether you really want to accept the type:
          audio/MicrosoftEncryp tedProprietaryC opyright2005DoN otCopyOrYoullBe DamnedToHell

          Gordon L. Burditt

          Comment

          Working...