You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Poynter, Stephen" <St...@ps.net> on 2002/11/20 18:03:38 UTC

Struts file upload validation problem

I have just written a document upload tool for a customer using the struts
upload functionality.  My upload jsp consists of one form that is of course
a multipart/form-data form.  The form consists of the file field along with
other text fields where the user enters various information( owner, title,
etc.) about the file to be uploaded.  The problem I'm having is that once
you submit the form struts immediately starts uploading the file before any
of the other data in the form is validated.  So, in my case, the user tries
to upload a large file but enters invalid information for the other text
fields.  Struts then uploads the file before validating the form data.  So
when the user corrects their mistake they have to re-upload the file yet
again.  Is it possible to have the form data validated before the file is
uploaded?  I would rather not use javascript for error checking.  Any help
is appreciated.  Thanks...

Steve


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts file upload validation problem

Posted by Mark Lepkowski <Ma...@lmco.com>.
You could have the user enter the meta data first, and then after it's validated let the user choose the file to upload.
  ----- Original Message ----- 
  From: Poynter, Stephen 
  To: Struts Users Mailing List (E-mail) 
  Sent: Wednesday, November 20, 2002 12:03 PM
  Subject: Struts file upload validation problem


  I have just written a document upload tool for a customer using the struts
  upload functionality.  My upload jsp consists of one form that is of course
  a multipart/form-data form.  The form consists of the file field along with
  other text fields where the user enters various information( owner, title,
  etc.) about the file to be uploaded.  The problem I'm having is that once
  you submit the form struts immediately starts uploading the file before any
  of the other data in the form is validated.  So, in my case, the user tries
  to upload a large file but enters invalid information for the other text
  fields.  Struts then uploads the file before validating the form data.  So
  when the user corrects their mistake they have to re-upload the file yet
  again.  Is it possible to have the form data validated before the file is
  uploaded?  I would rather not use javascript for error checking.  Any help
  is appreciated.  Thanks...

  Steve


  --
  To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  For additional commands, e-mail: <ma...@jakarta.apache.org>

Re: Struts file upload validation problem

Posted by Martin Cooper <ma...@apache.org>.

On Wed, 20 Nov 2002, Eddie Bush wrote:

> Brian Hickey wrote:
>
> >Martin is correct :o)
> >
> >Also be aware that very very large files can exceed the setting of Java temp
> >space (memory) allocation is some containers and crash them.
> >
> >One approach that works is to write a simple file upload script in Perl.
> >This allows you to check content-type, size, etc. and reject the upload
> >before trouble happens. It is also platform independent to a "reasonable"
> >degree.
> >
> Unless I'm mistaken, the commons file-upload component can do this too.
>  Am I mistaken?

Commons FileUpload has a size threshold below which a part is retained in
memory, and above which it is streamed to disk, to prevent memory issues.
It also has another size threshold that determines the maximum total size
of a request that it will accept, beyond which it will throw up its hands
and refuse to process the request at all.

--
Martin Cooper


>
> >Just another $.02 worth...
> >
> >Brian
> >
> --
> Eddie Bush
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts file upload validation problem

Posted by Eddie Bush <ek...@swbell.net>.
Brian Hickey wrote:

>Martin is correct :o)
>
>Also be aware that very very large files can exceed the setting of Java temp
>space (memory) allocation is some containers and crash them.
>
>One approach that works is to write a simple file upload script in Perl.
>This allows you to check content-type, size, etc. and reject the upload
>before trouble happens. It is also platform independent to a "reasonable"
>degree.
>
Unless I'm mistaken, the commons file-upload component can do this too. 
 Am I mistaken?

>Just another $.02 worth...
>
>Brian
>
-- 
Eddie Bush




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts file upload validation problem

Posted by Brian Hickey <bh...@r-effects.com>.
Martin is correct :o)

Also be aware that very very large files can exceed the setting of Java temp
space (memory) allocation is some containers and crash them.

One approach that works is to write a simple file upload script in Perl.
This allows you to check content-type, size, etc. and reject the upload
before trouble happens. It is also platform independent to a "reasonable"
degree.

Just another $.02 worth...

Brian



----- Original Message -----
From: "Martin Cooper" <ma...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 20, 2002 1:16 PM
Subject: Re: Struts file upload validation problem


>
>
> On Wed, 20 Nov 2002, Poynter, Stephen wrote:
>
> > I have just written a document upload tool for a customer using the
struts
> > upload functionality.  My upload jsp consists of one form that is of
course
> > a multipart/form-data form.  The form consists of the file field along
with
> > other text fields where the user enters various information( owner,
title,
> > etc.) about the file to be uploaded.  The problem I'm having is that
once
> > you submit the form struts immediately starts uploading the file before
any
> > of the other data in the form is validated.  So, in my case, the user
tries
> > to upload a large file but enters invalid information for the other text
> > fields.  Struts then uploads the file before validating the form data.
So
> > when the user corrects their mistake they have to re-upload the file yet
> > again.  Is it possible to have the form data validated before the file
is
> > uploaded?  I would rather not use javascript for error checking.  Any
help
> > is appreciated.  Thanks...
>
> Just to clarify the process, Struts does not upload the file, the browser
> does. The file is part of the same request as the other fields in your
> form - it's one of the -parts- in the -multipart- request, as is each of
> the remaining fields. Struts can't start working on the request until it
> is complete, including the file upload.
>
> If you need to do validation before the file is uploaded, you either need
> to use JavaScript in the browser, or use a separate page for the other
> fields, so that you can validate them server-side before the file is
> uploaded from its own page.
>
> --
> Martin Cooper
>
>
> >
> > Steve
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts file upload validation problem

Posted by Martin Cooper <ma...@apache.org>.

On Wed, 20 Nov 2002, Poynter, Stephen wrote:

> I have just written a document upload tool for a customer using the struts
> upload functionality.  My upload jsp consists of one form that is of course
> a multipart/form-data form.  The form consists of the file field along with
> other text fields where the user enters various information( owner, title,
> etc.) about the file to be uploaded.  The problem I'm having is that once
> you submit the form struts immediately starts uploading the file before any
> of the other data in the form is validated.  So, in my case, the user tries
> to upload a large file but enters invalid information for the other text
> fields.  Struts then uploads the file before validating the form data.  So
> when the user corrects their mistake they have to re-upload the file yet
> again.  Is it possible to have the form data validated before the file is
> uploaded?  I would rather not use javascript for error checking.  Any help
> is appreciated.  Thanks...

Just to clarify the process, Struts does not upload the file, the browser
does. The file is part of the same request as the other fields in your
form - it's one of the -parts- in the -multipart- request, as is each of
the remaining fields. Struts can't start working on the request until it
is complete, including the file upload.

If you need to do validation before the file is uploaded, you either need
to use JavaScript in the browser, or use a separate page for the other
fields, so that you can validate them server-side before the file is
uploaded from its own page.

--
Martin Cooper


>
> Steve
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>