By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Coloring input type=file browse button; uploading mutiple files

P: n/a
Good afternoon.

The entire task that I'm trying to achieve is to allow a user to browse and
upload multiple files simultaneously, hiding the Browse button of <input>
tags of type="file" and replacing it with a button of my own background
color and text.

The file paths I'd like displayed in a textarea and then the files uploaded
at once.

The code chunks toward my goal I got from the Web (below) I think worked
before IE 5.0 but for me produces an "Access Denied" error.

Can anybody help with any part of my problem (coloring the browse button,
listing multiple chosen files in a textarea, uploading an artibrary number
of files at once)?

Thanks, Ron.

------- JavaScript -------------
function addFile(path) {
document.getElementById(\"picturesTextArea\").valu e = path;
document.getElementById(\"text\").focus();
return true;
}

------ HTML ------------
<td>
<input
type="file"
id="pictureFile"
name="pictureFile"
style="display:none;"
onpropertychange="if(event.propertyName=='value')
{addFile(this.value);}">
</input>");
<textarea
id="picturesTextArea"
name="picturesTextArea"
cols="75"
rows="3"
maxlength="200">
</textarea>
</td>");
<td>
<button type=\"button\"
"onClick=\"this.form.pictureFile.click();\">
AddPicture
</button>
</td>");

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
There are serious restrictions on file input boxes. I don't think
you're allowed to make them invisible, write to the box from
javascript, or maybe even read from it anymore. The reason is then I
can "choose" a file on your system and upload it without you knowing
it. It's a slippery slope. You're probably better off either sticking
with what's "normal" or writing an ActiveX/Applet/Flash/etc code to do
what you need.
Mike
"Ron Brennan" <rb******@magma.ca> wrote in message news:<9d********************@magma.ca>...
Good afternoon.

The entire task that I'm trying to achieve is to allow a user to browse and
upload multiple files simultaneously, hiding the Browse button of <input>
tags of type="file" and replacing it with a button of my own background
color and text.

The file paths I'd like displayed in a textarea and then the files uploaded
at once.

The code chunks toward my goal I got from the Web (below) I think worked
before IE 5.0 but for me produces an "Access Denied" error.

Can anybody help with any part of my problem (coloring the browse button,
listing multiple chosen files in a textarea, uploading an artibrary number
of files at once)?

Thanks, Ron.

------- JavaScript -------------
function addFile(path) {
document.getElementById(\"picturesTextArea\").valu e = path;
document.getElementById(\"text\").focus();
return true;
}

------ HTML ------------
<td>
<input
type="file"
id="pictureFile"
name="pictureFile"
style="display:none;"
onpropertychange="if(event.propertyName=='value')
{addFile(this.value);}">
</input>");
<textarea
id="picturesTextArea"
name="picturesTextArea"
cols="75"
rows="3"
maxlength="200">
</textarea>
</td>");
<td>
<button type=\"button\"
"onClick=\"this.form.pictureFile.click();\">
AddPicture
</button>
</td>");

Jul 17 '05 #2

P: n/a
There are serious restrictions on file input boxes. I don't think
you're allowed to make them invisible, write to the box from
javascript, or maybe even read from it anymore. The reason is then I
can "choose" a file on your system and upload it without you knowing
it. It's a slippery slope. You're probably better off either sticking
with what's "normal" or writing an ActiveX/Applet/Flash/etc code to do
what you need.


Mike,

After a lot of work over the last few days this is what I believe to be
true:
1) I must click on the original browse button
2) I can read the selected path from the field, at least up to IE 5.0. Maybe
one can't with version 6.

Thanks,
Ron.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.