Radio Buttons used for FileUploaders?

Discussion in 'HTML' started by Johnny, Dec 30, 2007.

  1. Johnny

    Johnny Guest

    I need some help guys. I'm trying to modify a working MIDI ringtone
    uploader (HTML code) to use radio buttons rather than the standard
    "<INPUT type=>" file selector so the user doesn't have to browse and
    choose from hundreds of MIDI files or manually type the MIDI filename
    into the input box.


    How do I replace this:

    <INPUT type=file name=file>

    With FOUR simple radio buttons like this:

    <input type="radio" name="song" value="song1.mid">
    <input type="radio" name="song" value="song2.mid">
    <input type="radio" name="song" value="song3.mid">
    <input type="radio" name="song" value="song4.mid">

    When I replace <INPUT type=file name=file> with the above radio
    buttons and try it out the server returns this error: "Upload Failed,
    Please Pickup a valid audio file".

    But the files are VALID they work fine using <INPUT type=file
    name=file> but not with the radio buttons. What am I missing here? The
    MIDI's are in the same directory as the HTML file, I even tried
    changing the radio button values to the "Exact" file location ie:
    value="c:/midi/song1.mid" and it still doesn't work. Any suggestions?
    I'm willing to use a drop down box instead but I'd need to see some
    sample code of how that's done.
    Johnny, Dec 30, 2007
    #1
    1. Advertising

  2. Johnny

    Neredbojias Guest

    Well bust mah britches and call me cheeky, on Sun, 30 Dec 2007 05:26:25 GMT
    scribed:

    > I need some help guys. I'm trying to modify a working MIDI ringtone
    > uploader (HTML code) to use radio buttons rather than the standard
    > "<INPUT type=>" file selector so the user doesn't have to browse and
    > choose from hundreds of MIDI files or manually type the MIDI filename
    > into the input box.
    >
    >
    > How do I replace this:
    >
    > <INPUT type=file name=file>
    >
    > With FOUR simple radio buttons like this:
    >
    > <input type="radio" name="song" value="song1.mid">
    > <input type="radio" name="song" value="song2.mid">
    > <input type="radio" name="song" value="song3.mid">
    > <input type="radio" name="song" value="song4.mid">
    >
    > When I replace <INPUT type=file name=file> with the above radio
    > buttons and try it out the server returns this error: "Upload Failed,
    > Please Pickup a valid audio file".
    >
    > But the files are VALID they work fine using <INPUT type=file
    > name=file> but not with the radio buttons. What am I missing here? The
    > MIDI's are in the same directory as the HTML file, I even tried
    > changing the radio button values to the "Exact" file location ie:
    > value="c:/midi/song1.mid" and it still doesn't work. Any suggestions?
    > I'm willing to use a drop down box instead but I'd need to see some
    > sample code of how that's done.


    Using radio buttons for file uploads in forms doesn't work because
    currently only inputs can be "file select" (upload) elements.

    --
    Neredbojias
    Riches are their own reward.
    Neredbojias, Dec 30, 2007
    #2
    1. Advertising

  3. Scripsit Johnny:

    > I need some help guys. I'm trying to modify a working MIDI ringtone
    > uploader (HTML code) to use radio buttons rather than the standard
    > "<INPUT type=>" file selector


    You cannot.

    > so the user doesn't have to browse and
    > choose from hundreds of MIDI files or manually type the MIDI filename
    > into the input box.


    File input is awkward, the way it has been implemented in browsers. But
    that's what you need to play with, unless you want to try something
    difficult using client-side scripting, where you will probably encounter
    serious problems classifiable as "security settings".

    > How do I replace this:
    >
    > <INPUT type=file name=file>


    You don't.

    > With FOUR simple radio buttons like this:
    >
    > <input type="radio" name="song" value="song1.mid">
    > <input type="radio" name="song" value="song2.mid">
    > <input type="radio" name="song" value="song3.mid">
    > <input type="radio" name="song" value="song4.mid">


    That's just controls for selecting between four alternatives and
    resulting in data like song=song1.mid added to the form data set. There
    is no association with any files in the user's system. The data is just
    a string of characters. Naturally, when the server receives it, it has
    no way of using the data to access files in the user's system.

    File input works in a different way: the browser copies the _content_ of
    the selected file into the form data (possibly together with its file
    name, which is usually irrelevant to the server),

    > When I replace <INPUT type=file name=file> with the above radio
    > buttons and try it out the server returns this error: "Upload Failed,
    > Please Pickup a valid audio file".


    No wonder. No audio file was sent.

    > But the files are VALID they work fine using <INPUT type=file
    > name=file> but not with the radio buttons. What am I missing here?´


    The idea of file input. See my dusty old page on it:
    http://www.cs.tut.fi/~jkorpela/forms/file.html

    > The
    > MIDI's are in the same directory as the HTML file, I even tried
    > changing the radio button values to the "Exact" file location ie:
    > value="c:/midi/song1.mid" and it still doesn't work.


    It's not supposed to work. Such a string is still just a string. No
    software involved tries to interpret it as any kind of file name. If the
    server tried to do that, what good would it do to access _is_ C disk (if
    any)? Accessing the user's C disk would involve a horrendous security
    problem (even if such access from server to client would be limited to
    read-only).

    > I'm willing to use a drop down box instead


    Not possible either.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Dec 30, 2007
    #3
  4. Johnny

    Johnny Guest

    On Sun, 30 Dec 2007 12:04:21 +0200, "Jukka K. Korpela"
    <> wrote:

    >Scripsit Johnny:
    >
    >> I need some help guys. I'm trying to modify a working MIDI ringtone
    >> uploader (HTML code) to use radio buttons rather than the standard
    >> "<INPUT type=>" file selector

    >
    >You cannot.
    >
    >> so the user doesn't have to browse and
    >> choose from hundreds of MIDI files or manually type the MIDI filename
    >> into the input box.

    >
    >File input is awkward, the way it has been implemented in browsers. But
    >that's what you need to play with, unless you want to try something
    >difficult using client-side scripting, where you will probably encounter
    >serious problems classifiable as "security settings".
    >
    >> How do I replace this:
    >>
    >> <INPUT type=file name=file>

    >
    >You don't.
    >
    >> With FOUR simple radio buttons like this:
    >>
    >> <input type="radio" name="song" value="song1.mid">
    >> <input type="radio" name="song" value="song2.mid">
    >> <input type="radio" name="song" value="song3.mid">
    >> <input type="radio" name="song" value="song4.mid">

    >
    >That's just controls for selecting between four alternatives and
    >resulting in data like song=song1.mid added to the form data set. There
    >is no association with any files in the user's system. The data is just
    >a string of characters. Naturally, when the server receives it, it has
    >no way of using the data to access files in the user's system.
    >
    >File input works in a different way: the browser copies the _content_ of
    >the selected file into the form data (possibly together with its file
    >name, which is usually irrelevant to the server),
    >
    >> When I replace <INPUT type=file name=file> with the above radio
    >> buttons and try it out the server returns this error: "Upload Failed,
    >> Please Pickup a valid audio file".

    >
    >No wonder. No audio file was sent.
    >
    >> But the files are VALID they work fine using <INPUT type=file
    >> name=file> but not with the radio buttons. What am I missing here?´

    >
    >The idea of file input. See my dusty old page on it:
    >http://www.cs.tut.fi/~jkorpela/forms/file.html
    >
    >> The
    >> MIDI's are in the same directory as the HTML file, I even tried
    >> changing the radio button values to the "Exact" file location ie:
    >> value="c:/midi/song1.mid" and it still doesn't work.

    >
    >It's not supposed to work. Such a string is still just a string. No
    >software involved tries to interpret it as any kind of file name. If the
    >server tried to do that, what good would it do to access _is_ C disk (if
    >any)? Accessing the user's C disk would involve a horrendous security
    >problem (even if such access from server to client would be limited to
    >read-only).
    >
    >> I'm willing to use a drop down box instead

    >
    >Not possible either.



    Thanks Jukka your explanation makes sense and your web site was
    fantastic reading. I learned a lot. Thanks again.
    Johnny, Dec 31, 2007
    #4
  5. Johnny

    dorayme Guest

    In article <>,
    Johnny <> wrote:

    > Thanks Jukka your explanation makes sense and your web site was
    > fantastic reading. I learned a lot. Thanks again.


    If you read more of him, you would not quote so unnecessarily.

    --
    dorayme
    dorayme, Dec 31, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    613
  2. Scott D Johnson
    Replies:
    1
    Views:
    1,062
    Scott D Johnson
    Sep 27, 2006
  3. robert112
    Replies:
    2
    Views:
    393
    robert112
    Jun 25, 2007
  4. Dr. Leff
    Replies:
    3
    Views:
    290
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    219
    David Mark
    Oct 15, 2007
Loading...

Share This Page