How to change extension filters within Upload component ?


I would like to configure the extension filters within the web browser’s native file browser.
For now I am using the StartedListener to check the extension of the file, but it is still a workaround for me.

Any idea would be gratefully appreciated !


As far as I know it is not possible with html file input. Using swfupload (flash file upload helper) based upload widget might be an option if it is really needed. Still, I’d be surprised if it works well cross platform.


You could implement RFC 1867

Supported by Opera 11+, Chrome 16+ and Firefox 9+


It should be possible to add support to specify the accept attribute for an Upload component.

enhancement request #8857
not to forget this.

The simplest solution I found was to modify the input tag inside Upload component by this jQuery expression:

JavaScript.getCurrent().execute(“$(‘.gwt-FileUpload’).attr(‘accept’, ‘application/pdf’);”);

This should be executed after the Upload component as been added to its parent layout.[font=Courier New]