Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recursive file upload to a HttpServlet

 
Ulrich Vormbrock
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm wondering if it's possible to do a sequential file upload.
The situation is the following:

1. I make a simple file upload - descriptor.dsc - to a HttpServlet - this works fine!
2. The Servlet analyzes this file - it deals with a descriptor file which contains path infos of the LOCAL file system, belonging to the same project (also this works fine, the Servlet lists all files described in the uploaded descriptor file)
3. The user now has the possibility to choose which files (of the local file system) have to be uploaded now (realized with checkboxes)
4. That's my issue: I'm searching for a possibility to upload automatically all SELECTED files by the user.

To give an example, let's have a look at the local filesystem:
c:/project/descriptor.dsc
c:/project/unit1/image1.img
c:/project/unit1/image2.img
c:/project/unit2/image3.img
c:/project/unit2/image4.img
c:/project/unit3/image5.img


Due to the fact that most browser satisfy the security restritions, it's unlikely to get the file system infos (in our case: "c:/project") when I upload the file "descriptor.dsc" (which points to image1 ... image5).
Now it seems unpossible to tell to my routine something like "take the directory 'C:/project' and upload all files under unit1, unit2, etc.".

My Servlet thus only displays the relative file system, like
unit1/image1.img
unit1/image2.img
unit2/image3.img
unit2/image4.img
unit3/image5.img


In any case, if the user chooses for example "image1.img" and "image3.img", I would like to perform an automatic file upload, without having to choose such files manually by the html file input control. But I fear it's not possible, for security reasons, is it correct?

if there's a workaround, please let me know.
Without Flash, perhaps with Ajax oder even Java applets.

Many thanks in advance.
 
Tim Moores
Bartender
Posts: 2789
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While an HTML form can upload several files, there's nothing in HTML or JavaScript that would let it examine the local file system in order to figure out what those files should be.

A signed Java applet would have full control over the local file system, and could easily do this.
 
Ulrich Vormbrock
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Tim!

I already feared this - concerning an appropriate Java applet, do you know a product which can perform such task, for example an OpenSource product which enables the developer to interfere concerning the storage and examination of the local file system?
 
Tim Moores
Bartender
Posts: 2789
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't used one myself, but a search for java applet file upload finds numerous implementations.
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulrich Vormbrock wrote:Thank you, Tim!

I already feared this - concerning an appropriate Java applet, do you know a product which can perform such task, for example an OpenSource product which enables the developer to interfere concerning the storage and examination of the local file system?


Like Tim has suggested, only Applet can have permission (if signed) to read the local file system fully.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic