HTMLInputFile not settable

U

UJ

Guys,
I know this isn't the appropriate place to post this because it's HTML not
ASP.Net but I need some guidance. I have a web page with an HTMLInputFile on
it. The person enters the stuff, that's all great. They go to the next page
and I allow them to click a button to go back a page to change values. When
I go back one page, I want the HTMLInputFile to be filled in with the
previously loaded value (which I have saved somewhere) but there's no way to
set it. I get a The value property on HtmlInputFile is not settable error
message.

Anybody have any suggestions on what I can do?

TIA - Jeffrey.
 
B

Bruce Barker

browser security prevents this, so even if you bypass the asp.net check, it
will be ignored.

-- bruce (sqlwork.com)
 
U

UJ

Can anybody give me help on this?

Again the problem is - I have a page with an HTMLInputFile that I want to
preload with a value.

Can anybody make any suggestions on a way around this? The only thing I can
think of is to make two fields - one that is the name of the file to use,
and one used to upload the file. They would have to fill in the upload file
first - then that would set the value.

TIA - Jeffrey.
 
P

Patrice

Not sure but it looks like your want the other way round compared with your
workaround (i.e. fill programmatically the HtmlInputFile (input type=file
HTML tag) from an existing value).

To make sure, the problem is that the "value" property for this tag is read
only. the only mean to fill this field with the value is having the user
select a file. This is done for safety reason as otherwise you could upload
files from a web client without user permission.

And the only mean to upload a local file (with HTML alone) is to use this
tag.

A trick could be to have some fields inside an IFRAME, it would allows to
refresh those fields without touching the HTMLInputFile but my first option
would be rather to see if I can change the UI...

Patrice
--
 
Joined
Jan 15, 2009
Messages
1
Reaction score
0
HtmlInputFile setting value

You can create a HtmlInputText field with HtmlInputFile field directly to the right of it then create a Javascript function to fill a regular "text" input element after the user select the file.

<input type="text" id="FileName" name="FileName" runat="server" size="140">

<input type="file" id="FileName1" name="FileName1" class="fileupload" runat="server" size="1" onpropertychange="FileName_PropertyChange();">

Create a class like below for the "file" tag.

.fileupload
{
border: 0px none #FFFFFF;
background-color: #FFFFFF;
color: #FFFFFF;
text-decoration: none;
width: 10px;
height: 20px;
}

Then create the javascript function like below.

function FileName_PropertyChange()
{
document.tx_outputfile.value = document.tx_outputfile1.value;
}
 
Last edited:

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top