Reputation: 15710
I'm creating UI for backup and restore database in my J2EE app. I need to allow user to select a directory in his PC hard drive to save database backup.
I can select sql
file to carry out restoration by this. <input type="file" accept=".sql">
.
But i'm unable to find a way to select directory to save database backup file. I have google about this and found that there is no any way to select directories with jsp/html file.
Is there any way to achieve this ?
Upvotes: 0
Views: 1285
Reputation: 3146
For security reasons browser will not allow you to select a folder on the users local drive to store files in.
What you can do is set the Content-Disposition header at the moment the file is sent to the client (browser). In that case the browser will show as 'Save as' dialog. With this the user can select the folder to store the files in.
See this page on how to set the content disposition header.
res.setHeader("Content-Disposition", "attachment; filename=\"" + filename +"\"");
res.setContentType("application/octet-stream");
Upvotes: 2