I would like to trigger a click on the browse button on a hidden FileUpload widget. The following code works fine on IE 6+, but doesn’t work in FireFox.
final FileUpload upload = new FileUpload(); upload.setVisible(false); upload.setName('uploadFormElement'); panel.add(upload); panel.add( new Button('Select File', new ClickListener() { public void onClick(Widget pSender) { jsClickUpload( upload.getElement() ); } })); native void jsClickUpload( Element pElement ) /*-{ pElement.click(); }-*/;
How can I achieve the same in FireFox (and possibly other browsers)?
The solution can be read here:
http://www.quirksmode.org/dom/inputfile.html
in the last paragraph: