How to upload multiple files into a server location at a single time

Hi All,

In my application i need to send multiple files from a particular page into the server location. In this page there will be an option to upload a file and after selecting the file , we will have an option asking if we were interested to send another file. It works just similar to google mail where we can multiple files at the same time. Right now though i had coded the uploading files concept i am facing some problems when trying to upload multiple files. All the files are being appended to a single file but i want them to be placed as different files at the specified location. Plz help me in this regard...

Thanks in advance................,,

[677 byte] By [autoa] at [2007-10-2 21:50:45]
# 1
Try using some upload utils like commons upload of jakarta people..rgdsshanu
mshanua at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
THanks for u reply, i am trying to use apche commons-fileupload for this purpose, can you suggest me any other way to complete this task because using apche commons for the first time is taking me some time as i am not able to find any sample programs which does the work.
autoa at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Its not a big deal, using commons upload..u can even get sample code from their site..let me know if u are stuck any where..put the jar files inside ur lib folder and start using the package........regardsshanu
mshanua at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You can also try the Jenkov HTTP Multipart File Upload. It's a servlet filter that is easy to add to your web-project. After adding it, you can access both request parameters and the uploaded files easily. It's more transparent than Apache Commons File Upload. There is sufficient documentation to get you started, and there is a forum if you have any questions.

Jenkov HTTP Multipart File Upload is available under the Apache license, meaning its free to use.

jjenkova at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Jenkov HTTP Multpart File Upload also supports upload of multiple files.
jjenkova at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hai, i am using apche commons for uploading the multiple files but the problem i am facing is as follows. In the program i had mentioned the maximum capacity of files to be uploaded as 5 i.e., only 5 files are to be uploaded. And when i am trying to upload, if i upload 5 files, it is working fine but if i upload less than 5 files its not working and am getting some problems. So i had to upload only the maximum capacity files and not less than that. In the above example if i upload 2 or 3 files and say submit its not working. If i select 5 files and say submit its working and all the 5 files are being uploaded. Any remedy for this problem.....

autoa at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

The problem i am facing is that when i try to upload less no. of files than the maximum no. of files that can be uploaded, the program is not able to read the last file that is uploaded and am getting access denied error. But when i try to upload the maximum no. of files i can, i am not getting any problem and the files are uploaded perfectly. please help me out. can anyone provide me the sample program or example program for using apache commons. Thanks in advance

autoa at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Haii boss...could u just tell me where u customizin the number of files to be uploaded?regardsShanu
mshanua at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Hi,

i am sending the code in my prg. Have a look at it.

var multi_selector = new MultiSelector( document.getElementById( 'files_list' ),3);

In the above line i am specyfying that the maximum no. of files to be uploaded is 3. So if i upload less than 3 files, the program doesn't work and is not reading the uploaded files. If i upload 3 files it works fine. So please suggest me how to make this work irrespective of the no. of files uploaded using apache commons.

My code is as follows:

<form action="./servlet/Sample" method = "post" enctype="multipart/form-data">

<!-- The file element -- NOTE: it has an ID -->

<input id="my_file_element" type="file" name="file_1" >

<input type="submit" name="submit1" value="submit">

</form>

Files:

<!-- This is where the output will appear -->

<div id="files_list"></div>

<script>

<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->

var multi_selector = new MultiSelector( document.getElementById( 'files_list' ),3);

<!-- Pass in the file element -->

multi_selector.addElement( document.getElementById( 'my_file_element' ) );

</script>

autoa at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

I think the below code is a third party contribution..so not able to figure out what the function does.........

> <script>

> <!-- Create an instance of the multiSelector class,

> , pass it the output target and the max number of

> files -->

> var multi_selector = new MultiSelector(

> ( document.getElementById( 'files_list' ),3);

> <!-- Pass in the file element -->

> multi_selector.addElement( document.getElementById(

> ( 'my_file_element' ) );

>

> </script>

regards

Shanu

mshanua at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11
You could also try an applet (on client side) to allow mulitple file selection. Have a look to jClientUpload : http://www.javazoom.net/applets/jclientupload/jclientupload.htmlIt will work with your JSP (jakarta fukeupload-based) script.Hope it helps.
javazooma at 2007-7-14 1:06:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...