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

Filename for Uploading

P: n/a
I have a form that asks the user to upload a file. I have a field on this
form and I want to re-populate this form if it do not pass a validation
function. All other fields let me set the VALUE. I understand that the
"file" input type is different.

How can I re-populate the file name in this type of field. I have tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out value="${param.datafile2}"
/>" size="40">

Any ideas?


Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <41**********@127.0.0.1>, ti*********@brewersmarine.com
says...
I have a form that asks the user to upload a file. I have a field on this
form and I want to re-populate this form if it do not pass a validation
function. All other fields let me set the VALUE. I understand that the
"file" input type is different.

How can I re-populate the file name in this type of field. I have tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out value="${param.datafile2}"
/>" size="40">

Any ideas?


Although the HTML spec. permits pre-population of the value field, most
browsers disallow this for security reasons.

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #2

P: n/a
"Hywel Jenkins" <hy**********@hotmail.com> wrote in message
news:MP************************@news.individual.ne t...
In article <41**********@127.0.0.1>, ti*********@brewersmarine.com
says...
I have a form that asks the user to upload a file. I have a field on
this
form and I want to re-populate this form if it do not pass a
validation
function. All other fields let me set the VALUE. I understand that
the
"file" input type is different.

How can I re-populate the file name in this type of field. I have
tried the
following statement but it does not work ...

<input type="file" name="datafile2" value="<c:out
value="${param.datafile2}"
/>" size="40">

Any ideas?


Although the HTML spec. permits pre-population of the value field,
most
browsers disallow this for security reasons.


Here is my suggestion:

< if (param.datafile2 contains a value) then >
Selected file: <span style="font-family:monospace;">="<c:out
value="${param.datafile2}" /></span> (copy/paste this into the following
input)
< end if >
File to be uploaded: <input type="file" name="datafile2" size="40">

This way, users don't have to browse for the file again, they can simply
copy/paste the value they see into the input. It's more cumbersome than
populating the <input ... value="...">, but that's the price you pay for
using a browser as your UI.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

P: n/a
Since it's not possible to repopulate a file input field I wonder
consider dividing your form into 2 pages. The first page would take all
the user's details except the file and perform validation on that, and
the second page would just ask the user for the file.

Some nice side effects of this 2 step approach is that you are not even
bothering to receive files from user's who's data doesn't pass your
validation. And the other is that if the file uploaded takes 2 minutes
over a modem the user doesn't have to wait 2 minutes before finding out
their data was invalid.

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.