You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Volker Schneider <vo...@danet.de> on 2002/11/10 22:32:26 UTC

enctype="multipart/form-data" problem

Dear colleagues,

if have a form and I want to upload a file from that form. When I define my
form as

<form name="form2" enctype="multipart/form-data" method="post">

the ordinary input fields will not be transferred.

When I use method="get" it works. Unfortunately I have to use the "post"
method because I have to transfer a lot of data and I'm not sure, whether
this is possible with the "get" method (because of limited URL length).

Splitting the form is not possible, because I need the rest of the data too.

Please help me, what can I do?

Thank you, best regards
- Volker -


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


RE: enctype="multipart/form-data" problem

Posted by Geoff Howard <co...@yahoo.com>.
It is already fixed in 2.0.3, the release version:

    private Hashtable readHeaders(TokenStream in)
throws IOException {

        Hashtable headers = new Hashtable();
        String hdrline = readln(in);

        while (!"".equals(hdrline)) {
            StringTokenizer tokenizer = new
StringTokenizer(hdrline);

            headers.put(tokenizer.nextToken("
:").toLowerCase(),
                        tokenizer.nextToken(" :;"));

	        // The extra tokenizer.hasMoreTokens() in
headers.put
	        // handles the filename="" case IE6 submits
for an empty
	        // upload field.
            while (tokenizer.hasMoreTokens()) {
                headers.put(tokenizer.nextToken("
;=\""),
                            tokenizer.hasMoreTokens()
? tokenizer.nextToken("=\"") : "");
            }

            hdrline = readln(in);
        }

        return headers;
    }


--- Volker Schneider <vo...@danet.de>
wrote:
> Hi myself,
> 
> this is a bug in MultipartParser.java in the
> readHeaders() method within
> Cocoon 2.0.2.
> 
> When you define <form name="form2"
> enctype="multipart/form-data"
> method="post"> and you use a <input
> name="uploadedfile" type="file"> field,
> the header will contain:
> 
> ...name="uploadedfile"; filename=""
> 
> When filename is empty the StringTokenizer in
> readHeaders() will have no
> more tokens, but will get a nextToken() call.
> 
> Here's an approach for a bug fix:
> 
> ...
> while (tokenizer.hasMoreTokens())
> {
>   //---- old code
>   //  headers.put(tokenizer.nextToken(" ;=\""),
>   //          tokenizer.nextToken("=\""));
> 
>   //---- new code
>   String key = tokenizer.nextToken(" ;=\"");
>   String value = "";
>   if (tokenizer.hasMoreTokens())
>   {
>     value = tokenizer.nextToken("=\"");
>   }
>   else
>   {
>     value = "";
>   }
> 
>   headers.put(key, value);
>   //---- end of new code
> }
> 
> This helps unless the filename="" is not followed by
> an additional
> attribute, but it helps for the moment.
> 
> Please fix this bug, if it is not done yet.
> 
> Best regards
> - Volker -
> 
> 
> -----Original Message-----
> From: Volker Schneider
> [mailto:volker.schneider@danet.de]
> Sent: Sonntag, 10. November 2002 22:32
> To: cocoon-users@xml.apache.org
> Subject: enctype="multipart/form-data" problem
> 
> 
> Dear colleagues,
> 
> if have a form and I want to upload a file from that
> form. When I define my
> form as
> 
> <form name="form2" enctype="multipart/form-data"
> method="post">
> 
> the ordinary input fields will not be transferred.
> 
> When I use method="get" it works. Unfortunately I
> have to use the "post"
> method because I have to transfer a lot of data and
> I'm not sure, whether
> this is possible with the "get" method (because of
> limited URL length).
> 
> Splitting the form is not possible, because I need
> the rest of the data too.
> 
> Please help me, what can I do?
> 
> Thank you, best regards
> - Volker -
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <co...@xml.apache.org>
> For additional commands, e-mail:  
> <co...@xml.apache.org>
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <co...@xml.apache.org>
> For additional commands, e-mail:  
> <co...@xml.apache.org>
> 


__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


RE: enctype="multipart/form-data" problem

Posted by Volker Schneider <vo...@danet.de>.
Hi myself,

this is a bug in MultipartParser.java in the readHeaders() method within
Cocoon 2.0.2.

When you define <form name="form2" enctype="multipart/form-data"
method="post"> and you use a <input name="uploadedfile" type="file"> field,
the header will contain:

...name="uploadedfile"; filename=""

When filename is empty the StringTokenizer in readHeaders() will have no
more tokens, but will get a nextToken() call.

Here's an approach for a bug fix:

...
while (tokenizer.hasMoreTokens())
{
  //---- old code
  //  headers.put(tokenizer.nextToken(" ;=\""),
  //          tokenizer.nextToken("=\""));

  //---- new code
  String key = tokenizer.nextToken(" ;=\"");
  String value = "";
  if (tokenizer.hasMoreTokens())
  {
    value = tokenizer.nextToken("=\"");
  }
  else
  {
    value = "";
  }

  headers.put(key, value);
  //---- end of new code
}

This helps unless the filename="" is not followed by an additional
attribute, but it helps for the moment.

Please fix this bug, if it is not done yet.

Best regards
- Volker -


-----Original Message-----
From: Volker Schneider [mailto:volker.schneider@danet.de]
Sent: Sonntag, 10. November 2002 22:32
To: cocoon-users@xml.apache.org
Subject: enctype="multipart/form-data" problem


Dear colleagues,

if have a form and I want to upload a file from that form. When I define my
form as

<form name="form2" enctype="multipart/form-data" method="post">

the ordinary input fields will not be transferred.

When I use method="get" it works. Unfortunately I have to use the "post"
method because I have to transfer a lot of data and I'm not sure, whether
this is possible with the "get" method (because of limited URL length).

Splitting the form is not possible, because I need the rest of the data too.

Please help me, what can I do?

Thank you, best regards
- Volker -


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


Re: enctype="multipart/form-data" problem

Posted by Geoff Howard <co...@yahoo.com>.
I am using multipart/form-data uploads with post along
with input fields successfully in 2.1dev.  What
version are you using?  Can you confirm that the
parameters are not there by changing your form to
submit to the request generator example, just for
debugging purposes?  Also, can you confirm that your
file is being saved to disk?

Geoff Howard

--- Volker Schneider <vo...@danet.de>
wrote:
> Dear colleagues,
> 
> if have a form and I want to upload a file from that
> form. When I define my
> form as
> 
> <form name="form2" enctype="multipart/form-data"
> method="post">
> 
> the ordinary input fields will not be transferred.
> 
> When I use method="get" it works. Unfortunately I
> have to use the "post"
> method because I have to transfer a lot of data and
> I'm not sure, whether
> this is possible with the "get" method (because of
> limited URL length).
> 
> Splitting the form is not possible, because I need
> the rest of the data too.
> 
> Please help me, what can I do?
> 
> Thank you, best regards
> - Volker -
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <co...@xml.apache.org>
> For additional commands, e-mail:  
> <co...@xml.apache.org>
> 


__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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