Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select Directory

 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anyone know how to either in html or in JSP how to select a directory,

what i'm trying to do is to let the user press a button a web page and a pop-up dialog comes up where the user can select a directory to upload files from,

Any ideas - Thanks in advance,

Niall
 
Shashi Prakash
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file which suer is going to uplaod will be uploaded at server. right??

If yes then how can a user who is browsing can access your server or so...I

guess you should handle this directory oath from backend...
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a little HTML form that allows the user to select a file and upload it:This takes care of allowing a user to select a file from any directory. If you've ever attached a file to an e-mail in Hotmail or any other web e-mail program, they all use something like this only prettier.
 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the sample code

but

what im trying to do is to let the user press a button, perhaps "select directory", and a pop up screen comes up and the user can select a directory where there are multiple files that the user wants to upload,

the html code is brilliant for a single file but what happens if there is multiple files in a directory that the user wants to upload?

Thanks in advance
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The user can only upload one file per "input type=file" element. You could provide four of them, then the user could upload four files. HTML doesn't have anything fancy like what you are proposing.
 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sound Paul

but is it possible by JSP?
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the browser sees is HTML. It makes no difference whether you use JSP or something else to generate that HTML.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to write this yourself using Javascript on the client and Java on the server. For the client, use Javascript to create your popup.

For the server side of things, look at the java.io.File class to learn how to read directory structures from within Java.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic