How to transfer a file From Client to Server in GW

2019-09-02 05:57发布

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条回答
男人必须洒脱
2楼-- · 2019-09-02 06:12

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.

查看更多
登录 后发表回答