问题
I have code to browse a file .
i have to send the file to server side. I dont know how to pass file to Server Using RPC.
formPanel.addFormHandler(new FormHandler() {
public void onSubmitComplete(final FormSubmitCompleteEvent event) {
// TODO Auto-generated method stub
Window.alert(event.getResults());
}
public void onSubmit(final FormSubmitEvent event) {
// TODO Auto-generated method stub
event.setCancelled(true);
}
});
formPanel.setMethod(FormPanel.METHOD_POST);
formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
formPanel.setWidget(holder);
holder.add(upload);
btnAdd.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// *
}
});
// holder is vertical Panel
on this btnAdd clickhandler i have to transfer a file to server with all its contents. On serverside i have to read the content, file name. Plz help me with the Interface ,interfaceAsync ,service , and server side.
回答1:
Please see the link below.
http://commons.apache.org/fileupload/using.html
Also pls keep in mind that when you deploy the app you'll need commons-io-2.1.jar too.
来源:https://stackoverflow.com/questions/9259680/how-to-transfer-a-file-from-client-to-server-in-gwt-using-fileupload