Hi Jeff,
To upload files via the web your form must use the
enctype="multipart/form-data".
Unfortunately this encoding type is not natively supported by the Java
Servlet API (I'm not sure why this is so). Using the multipart/form-data
encoding type basically uploads all your form data as raw bytes. You needn't
worry about having to access your data as raw bytes however as there are a
number of tools out there that can assist you. Since you're using Struts
already it makes most sense to use the multipart/form-data support of
Struts. Have a look at this page
http://jakarta.apache.org/struts/userGuide/building_view.html#forms. This
gives you basic idea on how you can achieve this via Struts. I'll leave the
solution up to you can choose to go the whole Struts solution of you could
mix it up with ohtml.
If your form has a number of other fields besides just the file upload field
then you may want to use Struts and ohtml together. You can do this as such:
1. Create a normal ohtml form but set the attribute
enctype="multipart/form-data" of the <form> tag.
2. Create an ActionForm that has a set/get method for each file upload you
have.
3. In the perform() method of your Action you can extract the file details
via you ActionForm object (see example)
4. You can update the rest of your ohtml form using the updateData(request)
like normal in the perform method
Cheers,
Keith
----- Original Message -----
From: "Cooper, Jeff" <Jef...@us...>
To: <kei...@op...>
Sent: Wednesday, January 23, 2002 5:02 AM
Subject: HtmlFileInput use
> Keith,
>
> I'm trying to use the HtmlFileInput to let the user browse to a comma
> seperated file that i will then parse. Using the HtmlFileInput, how do i
> get access to that file. I saw the getSubmittedData method, but that only
> returns a string, is this the method i would use?
>
> Thanks,
> Jeff Cooper
|