You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Xephyrus <xe...@xephyrus.com> on 2003/03/15 05:27:04 UTC

[fileupload] access to non-file-related parameters?

Greetings,


I've been looking over the fileupload code with the hope of using it in an
upcoming project.  It looks like there's no way to access form parameters
that are not related to the file-upload.

For example, if I have an upload form that accepts the filename to upload
(via a normal file-type input tag) and a description of that file (via a
textarea, let's say), there's no way to retrieve the description.

Is this intentional?  If so, why?


Thanks,
.  Topher




Re: [fileupload] access to non-file-related parameters?

Posted by Xephyrus <xe...@xephyrus.com>.
>> For example, if I have an upload form that accepts the filename to
>> upload (via a normal file-type input tag) and a description of that
>> file (via a textarea, let's say), there's no way to retrieve the
>> description.
>
> The parseRequest() method returns a list of *all* the parameters in the
> request. In the case you describe, there would be two items in the
> list, one for the uploaded file and another for the description. You
> can access the text of your description with something like this:
>
>    if (item.isFormField() && "description".equals(item.getFieldName()))
>    {
>        String description = item.getString();
>        // Do what you want with the description.
>    }


Ah,  I had been wondering about that isFormField method.  Thanks.


.  Topher



Re: [fileupload] access to non-file-related parameters?

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

On Fri, 14 Mar 2003, Xephyrus wrote:

>
> Greetings,
>
>
> I've been looking over the fileupload code with the hope of using it in an
> upcoming project.  It looks like there's no way to access form parameters
> that are not related to the file-upload.
>
> For example, if I have an upload form that accepts the filename to upload
> (via a normal file-type input tag) and a description of that file (via a
> textarea, let's say), there's no way to retrieve the description.

The parseRequest() method returns a list of *all* the parameters in the
request. In the case you describe, there would be two items in the list,
one for the uploaded file and another for the description. You can access
the text of your description with something like this:

    if (item.isFormField() && "description".equals(item.getFieldName())) {
        String description = item.getString();
        // Do what you want with the description.
    }

--
Martin Cooper


>
> Is this intentional?  If so, why?
>
>
> Thanks,
> .  Topher
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>