Radio Buttons used for FileUploaders?

J

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 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.
 
N

Neredbojias

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.
 
J

Jukka K. Korpela

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.
 
J

Johnny

Scripsit Johnny:


You cannot.


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".


You don't.


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:
http://www.cs.tut.fi/~jkorpela/forms/file.html


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).


Not possible either.


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

dorayme

Johnny said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top