Take the 2-minute tour ×

I require a method by which users can input files and display the contents of the file in a GWT panel. The contents do not need to be sent to any server and I would prefer to keep the file client-side. I have tried the following:

  • Used the library lib-gwt-file. It works perfectly in Firefox, mostly works in Chrome, and does not work at all in Internet Explorer. I need to support all these browsers. I have emailed the author of the library but have not received a response.

  • Used a method such as this to use a FileUpload object and a FormPanel. However, my organization uses a security filter which requires headers be set in order to communicate with the server. I understand that headers cannot be set for a FormPanel.

  • I have investigated other file upload libraries for GWT such as GWTUpload but they don't really do what I want. I'm not looking to upload the file to my server, I just need the contents of the file client-side.

I am out of ideas and I don't know how I can accomplish this simple task. Does anyone have any suggestions on other methods or ways to get past my current roadblocks?

share|improve this question
Your 2nd option uses the standard GWT FileUpload this can be added to any type of Panel. It might help if you showed some code for the 2nd point. Don't know about other libs. –  Martin Nov 20 '12 at 16:32
I didn't bother adding code because my implementation is identical to the included link in every important way. I know that a FileUpload object can be added to any type of panel, but I don't know of any way to access the file contents other than by attaching to a FormPanel and submitting to a servlet. The documentation for FileUpload states that there is no other way unfortunately. –  breakspirit Nov 20 '12 at 17:48

2 Answers 2

up vote 1 down vote accepted

Using the lib-gwt-file API is the best way you're going to achieve this, since it encapsulates the HTML5 File API for GWT, which makes local file system access possible; local file system access isn't possible any other way as far as I know. Unfortunately, IE 9 and lower doesn't support the File API, so that's why lib-gwt-file doesn't work. The File API wasn't introduced to IE until IE10.

Edit: According to this SO answer, you can access the local file system in IE through ActiveX, but it's limiting and to use it with GWT you'll have to use JSNI to hand-write the JavaScript in your GWT code.

share|improve this answer

I can now fully answer my own question. Neeko was correct above but lib-gwt-file was not working properly for this use case. So, I contacted the maker of that library and explained the issues. He has solved the issue I was experiencing in Chrome and also has made the library work well with IE10. As Neeko said, IE9 is not supported.

In IE10, one must enable support for typedArrays by adding &mode=typeArrays to the end of the URL. This is a workaround to a bug in IE and will likely not always be necessary.

In Chrome, there is a Webkit bug wherein selecting the same file twice would no longer trigger a change event and thus one could not upload the same file twice in a row. There is a workaround for this in the next version of lib-gwt-file.

Firefox works fine as of version 0.3.2

So, if anyone else has tried to use this library and experienced these issues, it should now work better for you. The author of lib-gwt-file, Lukas Laag, was very helpful in solving these issues.

share|improve this answer
Glad to hear the author was able to help you out even further and make the bug fixes to the library. Thanks for posting the update. –  Neeko Nov 26 '12 at 21:09

Your Answer


