Multipart forms and cgi

Hi,

I’m having some trouble getting hidden fields to appear in multipart forms
working using cgi and mod_ruby.

ruby 1.8.1 (2003-10-31) [i686-linux]
apache 2.0.40
mod_ruby 1.1.1

I’m creating a multipart form using cgi.multipart_form(“sub.rhtml”) { … }
to generate the following html:

 <FORM METHOD="post" ENCTYPE="multipart/form-data" ACTION="sub.rhtml">
    <P>
      <INPUT NAME="privacy" SIZE="40" TYPE="text">
    </P>
    <BR>
    <P>
      Main Menu Mpeg:
      <INPUT NAME="mpeg" SIZE="" MAXLENGTH="50" TYPE="file">
    </P>
    <INPUT NAME="formname" TYPE="hidden" VALUE="testform">
    <INPUT TYPE="submit" VALUE="Save">
  </FORM>

but when I try to retrieve the value of the field like this:

cgi.params[‘formname’][0]

there doesn’t seem to be formname parameter.

This is the CGI.escape(cgi.inspect) string from the webbrowser (sorry
about the guff - the browser wouldn’t display the straight inspected
output):

%23%3CCGI%3A0x84bc59c+%40cookies%3D%7B%7D%2C+%40output_cookies%3Dnil%2C+%40multipart%3Dtrue%2C+%40output_hidden%3Dnil%2C+%40params%3D%7B%22privacy%22%3D%3E%5B%23%3CStringIO%3A0x84bc358%3E%5D%7D%3E

I can see the privacy StringIO in there but not ‘formname’. Hidden fields
seem to work on normal forms. Any ideas?

On a related note the std-lib documentation has a multipart? method for
CGI:QueryExtension but this doesn’t seem to be in the version of cgi I’ve
got. Is there a later version?

regards,

Martin

“Martin Stannard” martins@aardvark.net.au schrieb im Newsbeitrag
news:58208.203.22.14.128.1070418884.squirrel@www.aardvark.net.au

Hi,

I’m having some trouble getting hidden fields to appear in multipart
forms
working using cgi and mod_ruby.

ruby 1.8.1 (2003-10-31) [i686-linux]
apache 2.0.40
mod_ruby 1.1.1

I’m creating a multipart form using cgi.multipart_form(“sub.rhtml”) {
… }
to generate the following html:

 <FORM METHOD="post" ENCTYPE="multipart/form-data"

ACTION=“sub.rhtml”>

    <P>
      <INPUT NAME="privacy" SIZE="40" TYPE="text">
    </P>
    <BR>
    <P>
      Main Menu Mpeg:
      <INPUT NAME="mpeg" SIZE="" MAXLENGTH="50" TYPE="file">
    </P>
    <INPUT NAME="formname" TYPE="hidden" VALUE="testform">
    <INPUT TYPE="submit" VALUE="Save">
  </FORM>

but when I try to retrieve the value of the field like this:

cgi.params[‘formname’][0]

there doesn’t seem to be formname parameter.

Did you try cgi.params[‘formname’] also? What does it return?

This is the CGI.escape(cgi.inspect) string from the webbrowser (sorry
about the guff - the browser wouldn’t display the straight inspected
output):

%23%3CCGI%3A0x84bc59c+%40cookies%3D%7B%7D%2C+%40output_cookies%3Dnil%2C+%4
0multipart%3Dtrue%2C+%40output_hidden%3Dnil%2C+%40params%3D%7B%22privacy%2
2%3D%3E%5B%23%3CStringIO%3A0x84bc358%3E%5D%7D%3E

I can see the privacy StringIO in there but not ‘formname’. Hidden
fields
seem to work on normal forms. Any ideas?

Maybe the output is truncated. Maybe you you didn’t enter a file name
before submitting the form. …

Kind regards

robert

Hi Robert,

Maybe the output is truncated. Maybe you you didn’t enter a file name
before submitting the form. …

Kind regards

robert

There seems to be a bug in version 1.63 of cgi.rb when it comes to
multipart forms. After trying every combination of cgi[‘formname’],
cgi.param[‘formname’] etc it turns out it was only passing the first field
in the form.

I downloaded version 1.56 of cgi.rb from the cvs repository and replaced
1.63 and the multipart form now works correctly.

regards,

Martin