It's not a secret anymore!*
The moose likes Servlets and the fly likes Multiple File Upload from a directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple File Upload from a directory" Watch "Multiple File Upload from a directory" New topic

Multiple File Upload from a directory

Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Good day!

Is it feasible to upload all the files in a specified directory to a

I have tried file upload but it has the "browse" button for the files
to upload.

This time, I want to do it automatically that when the program starts,
all the contents of a specified directory will be uploaded.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41137
Since you posted this to the "Servlets" forum, I'm assuming that by "program" you mean a web application. In that case, no, this is not possible. And that's a good thing, too - think of the security implications if it were possible to upload user files automatically to a remote site.

Using the manual file selection via the "Browse..." button is the only way, and since that doesn't allow to select directories, it is not possible to upload a complete directory.

Ping & DNS - my free Android networking tools app
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your reply.

Yes, I am doing a web application. The sequence of my program is this, I have an applet that uploads files from client to server's file system. Now, I will validate/parse the contents of the said folder after which I will transfer the valid files to a specified folder for it to be uploaded to the database. What I am asking is that is it possible that I will upload the valid files one by one from the directory without using the "browse" button? I don't want to upload the whole directory.

Thanks again.

God bless.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Yes, if you are using a signed applet then it can do anything with the client's files that it likes. Assuming of course that the client accepts the notification the first time they download the applet.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your reply Paul!

So I guess, the final answer to the question "Can I upload the files FROM a directory to the database?" is: YES?

I agree. Here's the link:
subject: Multiple File Upload from a directory
Similar Threads
Directory Creation on FTP Server using Java Program
Upload all the files in the directory to server
Possible to get listing of all files in directory?
uploading files in JSP
doubt regarding Directory Upload using HTTPclient3.1 library