开发者

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(fileUploa开发者_运维知识库d);
panel.add(btnSubmit);


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.


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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜