Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Radio Buttons used for FileUploaders?
December 30, 2007, 5:26 am
rate this thread
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.
- Jukka K. Korpela
December 30, 2007, 10:04 am
Re: Radio Buttons used for FileUploaders?
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".
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),
No wonder. No audio file was sent.
The idea of file input. See my dusty old page on it:
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
Not possible either.
Jukka K. Korpela ("Yucca")