Multi File upload

Hi all,I need to use a FileUpload in a page and upload n files.What's the correct way to do this?Any examples?I've been thinking to store in a session parameter (File[ ])....It's a bad idea?thank's in advance!
[255 byte] By [NewLitusa] at [2007-11-27 7:42:49]
# 1

> Hi all,

> I need to use a FileUpload in a page and upload n

> files.

> What's the correct way to do this?Any examples?

>

> I've been thinking to store in a session parameter

> (File[ ])....

> It's a bad idea?

>

> thank's in advance!

First of all, every fileUpload component is good for one file only. So, if you need to upload n files, you simply need n fileUpload components. That said, you may use any of the following approaches:

1) If n is known beforehand, stack n fileUpload components and upload them one after the other. You need to be careful since if one of the files doesn't upload gracefully, you don't want to keep uploading files that have been uploaded correctly (a fileUpload component loses its input after an unsuccessful submit). You may need to make good use of virtual forms here.

2) If n is not known beforehand, easy. Once known, generate n fileUpload objects on the form programmatically.

3) If you still insist on wanting to upload the n files in one go, then may be you want to consider zipping them all first, upload the zipped file, and upzip it upon a successful upload. Java SE comes equipped with an API to help you zip and unzip a group of files from within your application. I could help you with the code if you need.

4) I don't have a 4 :-). If you get that (File[ ]) working, let us know please.

drMohsenMadia at 2007-7-12 19:23:44 > top of Java-index,Development Tools,Java Tools...
# 2
Sorry my english it's very poor and I think that not explain me correctly.I need to upload n files in one step but I want only one File upload component.Do you understand me?
NewLitusa at 2007-7-12 19:23:44 > top of Java-index,Development Tools,Java Tools...
# 3
> ...> Do you understand me?Yes I understand you, but it is you who doesn't understand me! If the English is too complex to you, use the services in http://www.google.com/language_tools.
drMohsenMadia at 2007-7-12 19:23:44 > top of Java-index,Development Tools,Java Tools...
# 4
Thank's for your suggestion referent to my english learning.
NewLitusa at 2007-7-12 19:23:44 > top of Java-index,Development Tools,Java Tools...