aspose file tools*
The moose likes Applets and the fly likes Recursive file upload to a HttpServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Recursive file upload to a HttpServlet" Watch "Recursive file upload to a HttpServlet" New topic
Author

Recursive file upload to a HttpServlet

Ulrich Vormbrock
Ranch Hand

Joined: Apr 15, 2010
Posts: 73
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.


SCJP 6 (88%), SCWCD (89%)
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Apr 15, 2010
Posts: 73
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
I haven't used one myself, but a search for java applet file upload finds numerous implementations.
Minh Nam
Ranch Hand

Joined: Sep 10, 2011
Posts: 57
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.


Advanced java topics
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursive file upload to a HttpServlet