0

What i want is that a user can select a complete path in his local drive and then a file (which is in the war folder of my app right now) will be saved in that selected user location

I am using File upload in GWT to upload my files , its working fine , will i use FileUpload for Download as well?

Also for a second option if there's a possibility to get the location which user have selected for example d:\downloadfolder, my problem will solve, i will do the rest !

below is the code for uploading , Please help me with Download

final String UPLOAD_ACTION_URL = GWT.getModuleBaseURL() + "upload";
initWidget(panelImages);
final FormPanel form = new FormPanel();
form.setAction(UPLOAD_ACTION_URL);

form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);

VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);

FileUpload upload = new FileUpload();
upload.setName("uploadFormElement");
panel.add(upload);

// Add a 'submit' button.
panel.add(new Button("Submit", new ClickHandler() {
    public void onClick(ClickEvent event) {
        form.submit();
    }
}));

form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
    public void onSubmitComplete(SubmitCompleteEvent event) {
        if(event.getResults().contains("DataBase Restored")){
            Window.alert("Database Restored !");
        }
    }
});

panelImages.add(form);
rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123
junaidp
  • 10,801
  • 29
  • 89
  • 137

1 Answers1

0

You can't do this from GWT because JavaScript has no access to the local hard drive. The best you can do is initiate a download normally (e.g. show a link to a file that the user can click). Depending on their browser settings they'll either choose a location for the file or it will be downloaded to some default location. You cannot know that location with just JavaScript.

If this is a project requirement I think you'll need to include a heavier-weight plugin like java or flash.

Riley Lark
  • 20,660
  • 15
  • 80
  • 128
  • thanks , yeah its a project requirement , let me give a quick brief , may be you can come up with some other idea , the purpose is llow the Admin for the site to take the sqldump of my current database and save it some where in pc. Right now i am saving the file in the war folder , its working fine ,Or is there a way user can see the files which are in the war folder ? – junaidp Feb 27 '13 at 16:42