How GWT fileupload works?

半世苍凉 提交于 2020-01-12 01:48:54

问题


Anybody know how GWT file upload works? I know about FileUpload widget and how to use it. I want to know what is its inner mechanism. We can't get contents of file from FileUpload widget in client and how it is going to server? I googled it but i didn't get solution.

Thanks in advance.


回答1:


GWT's file upload makes use HTML's input element. The html input element is native html dom element which allows to select files from your system.

After selection you need to submit it to your server. This is done by the GWT's FormPanel.

In particular, FileUpload is only useful when used within a FormPanel, because the browser will only upload files using form submission.

Note:

1) You can read about how to code with formpanel and fileupload as answered here @ Basic File upload in GWT

2) If you are concerned with processing the file on client side and not pushing the file to server then you have limited options as mentioned here @ How to retrieve file from GWT FileUpload component?




回答2:


formPanel.setAction(GWT.getModuleBaseURL()+"uploadHandler");     
formPanel.setMethod(Method.POST);

when we use formPanel.submit(),we can invoke the servlet and get the file upload details.



来源:https://stackoverflow.com/questions/15636380/how-gwt-fileupload-works

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!