footprint.
footprint.

Reputation: 21

how to get file using FileUpload GWT?

How can I get the uploaded file (for example a text file) to display in a string after it is selected?

FileUpload fileUpload = new FileUpload();
panel.add(fileUpload);
panel.add(btnSubmit);

Upvotes: 0

Views: 1302

Answers (2)

maneesh
maneesh

Reputation: 1701

In addition to what Jason said, if you want only the user selected file name, before sending to the server, you can use FileUpload#getFilename()

Upvotes: 0

Jason Terk
Jason Terk

Reputation: 6025

You can't get the contents of a file selected by the user without uploading it to your server first.

As explained in the FileUpload documentation a FileUpload needs to be wrapped in a FormPanel that uses multipart encoding. Once the form is submitted your application can request the file contents from the server (or they could be included in the response to the request that uploaded the file) and then displayed by your application.

Upvotes: 1

Related Questions