Closed Bug 178693 Opened 22 years ago Closed 22 years ago

<input type=file> element doesn't respond to click() method

Categories

(Core :: Layout: Form Controls, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 36619
Future

People

(Reporter: jpatadia, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826

I have a simple form as follows :

<form name="foo">
<input type="file" name="myfile">
</form>



What I want to do is in my body onload statement I want to do invoke the command :
document.foo.myFile.click() 

so that it can popup the open file dialog. This does not work, it does not even
throw a error in the javascript console.

Is this the desired behaviour - i tend to think it is a bug since I'ved tried
that with other browsers and it seemed to work.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.



Expected Results:  
Mozilla should support the click() command on the input type=file element.
Browser, not engine ---> DOM Level 0 for further triage 
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Summary: input type=file element doesn't respond to click event.... → <input type=file> element doesn't respond to click() method
Attached file testcase
The testcase does not work in Netscape 4.  It works in IE5.

The DOM spec says:

click
    Simulate a mouse-click. For INPUT elements whose type attribute has one of the
    following values: "button", "checkbox", "radio", "reset", or "submit".

"file" isn't in that list, really...  Over to form controls to see about this,
though our general attitude to letting JS mess with file upload controls in any
way (even like this) is "no".
Assignee: jst → form
Status: UNCONFIRMED → NEW
Component: DOM Level 0 → Layout: Form Controls
Ever confirmed: true
OS: Windows 2000 → All
QA Contact: desale → tpreston
Hardware: PC → All
I agree, this probably is not in the dom spec. However having this capability
would allow users to do automate some simple tasks in their browser.

The other use case I see for this feature is to be able to change the appearance
of the Browse button. In certain cases (especially if you are low on screen-real
estate you might want to change the browse button to look like an image. Having
the ability to perform a click on the input type=file would allow you to satisfy
this case.

For an example, look at :

http://www.faqts.com/knowledge_base/view.phtml/aid/6003/fid/177

Agreed, it is a contrived way to use the input type=file button, but in my
opinion it is best to let the users decide how they want to display their forms.

Thanks,
Jalpesh.
> to be able to change the appearance of the Browse button.

Which is something we're trying to prevent at all costs, since it leads to major
security issues...

In fact, implementing this method would allow the page to hide the file control
completely and just have a filepicker come up out of nowhere.  ccing some
security folks; they need to be in on this.

If a user wants to style the button, the user can already do that via
userContent.css, btw.  The site you are citing is for _web_developers_ wanting
to change the look, which is a totally different kettle of fish.
Priority: -- → P3
Target Milestone: --- → Future

*** This bug has been marked as a duplicate of 36619 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: