How to transfer a file From Client to Server in GWT using fileUpload

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 03:17:09

问题


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

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