btw:
What gets submitted for an empty file field?
Nothing, or null or... ?

-----Original Message-----
From: Andrew Hill [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 17, 2002 20:51
To: Struts Users Mailing List
Subject: Multiple file upload?


Haven't tried this yet so figured I better get advice on the best approach
before spending time on it.
I (will) have a form from which the user will be uploading multiple files
the number of which is not fixed.

Option A:
Since I dont have to support Nutscraper 4.x, it is a simple matter to create
additional file upload controls on demand with a bit of javascript using the
new DOM methods. My intent is to let the user choose as many files as they
wish , and then they will all submit under the same field name, so that
field on the ActionForm would have getters and setters for an array of
FormFile[]. Is this supported by the struts upload stuff (or indeed html)?
While the user can upload all the files at one go, they may have stuffed up
one of the other fields for validation and get sent back to the view. If
this happens I dont want them to have to upload all the files again. I also
need to provide an option to discard an uploaded file should the user have
second thoughts when they get back from a failed validation.

Option B:
I have one file upload control, and the property in the form takes a single
FormFile. The user selects one file and clicks a button. The form is
submitted immediately and that file uploaded and the the user is then
returned back to the same view. Above the file upload control is a list of
filenames of files uploaded. The user can repeat the process as required
until all their files are uploaded. When they have finished (and filled in
other fields etc...) they click ok and the form is submitted, and at this
point I pass these files sitting in tomcat somewhere over to my backend j2ee
application as normal. As before I need to provide the user the option to
remove a suddunly unwanted file from the list.

Option C:
This is a very simple approach that will only take me 5 minutes to code,
will work well and be much loved by users for its combined power and
simplicity. If you happen to know any further details about the actual
implementation of option C, please email me and tell me, cos I dont know
any... ;-)


In all the options I will need to keep hold of the files uploaded between
requests and somehow indicate to the users which files have already been
uploaded, and provide them with the option to remove those files they change
their minds about uploading. Only when validation is successful and the user
has finished should I be passing these files along with the other fields to
my backend j2ee application to process (at which point I need to clean up
the unwanted temp files in tomcat)

Some pointers on how to implement these requirements would be most
appreciated.

tia
Andrew


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to