calling click() method from javascript on file input form element does not work as expected

RESOLVED DUPLICATE of bug 201178

Status

--
major
RESOLVED DUPLICATE of bug 201178
14 years ago
14 years ago

People

(Reporter: carstenklein, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217


Calling the click() method of a file input form element does not open the file
requester, i.e.

<form name = "FileUploadTest" enctype = "multipart/form-data" method = "post"
action = "uploader.php">
<input style = "visibility:hidden;" type = "file" name = "FileUpload">
<input class = "FancyButton" value = "Upload" onClick = "if ( upload() )
document.forms[ \"FileUploadTest\" ].submit();";>
</form>

<script>
function upload()
{
     elt = document.forms[ "FileUploadTest" ].elements[ "FileUpload" ];
     elt.click();
     if ( elt.value != "" )
     {
         return true;
     }
     return false;
}
</script>


Reproducible: Always

Steps to Reproduce:
1. try the above semi-test-case
2.
3.

Actual Results:  
nothing

Expected Results:  
I would expect Mozilla to invoke the file requester in order to have a different
button instead of the default file input button, which is in no way styleable or
otherwise controllable.


Besides the aforementioned problem, the file input form element also does not
allow styling of the "Browse..."-labelled button at all. Furthermore, the label
I was not able to replace with a custom text, for example "Upload..." and, what
is more, I was not able to hide the input text box in favour of only providing a
Upload button that would fit nicer into the user interface scheme I am currently
developing for a site I am doing.

Is this a safety issue? If so, why the heck must we reasoning-capable people
suffer from the inability of some und consequently must develop web-applications
that are simply just way below what is expected for a standard user interface
compatible application and a given style guide that is to be expected to be
implemented?

Comment 1

14 years ago
Yes mostly a security issue.

*** This bug has been marked as a duplicate of 201178 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → DUPLICATE
Summary: calling click() method from javascript on file input form element does not work as expected → calling click() method from javascript on file input form element does not work as expected
You need to log in before you can comment on or make changes to this bug.