This most commonly happens when the request has already been parsed, or
processed in some other way. Since the input stream has aleady been
consumed by that earlier process, it is no longer available for parsing
by Commons FileUpload.
The most common cause of these exceptions is when FileUpload is being
used on a site that is using the Tomcat ISAPI redirector. There was a
bug in earlier versions of that component that caused problems with
multipart requests. The bug was fixed some time ago, so you probably
just need to pick up a newer version. See the
Tomcat bug report
for full details.
This most commonly happens when attempting to rely on a shared copy of
the Commons FileUpload jar file provided by your web container. The
solution is to include the FileUpload jar file as part of your own
web application, instead of relying on the container.
Internet Explorer provides the entire path to the uploaded file and not
just the base file name. Since FileUpload provides exactly what was
supplied by the client (browser), you may want to remove this path
information in your application. You can do that using the following
method from Commons IO (which you already have, since it is used by
FileUpload).
Struts recognises multipart requests, and parses them automatically,
presenting the request parameters to your code in the same manner as
if they were regular request parameters. Since Struts has already
processed the request, and made it available in your form bean, the
input stream is no longer available for parsing, so attempting to do
so with FileUpload will fail.
Struts parses multipart a request as a part of the process of populating
your form bean from that request. If, for some reason, you need to have
full control over the multipart parsing, you can do so by configuring
your action mapping without an associated form bean. (A better way of
doing this, however, is to replace the default multipart handler with
your own. See the Struts documentation for details.)