dmorgo has asked for the wisdom of the Perl Monks concerning the following question:
Jokes about upgrading to Linux are appreciated here just as much as at any monastery, but unfortunately not just supplicants, but masses of aspiring supplicants will be using this and they could be running just about anything.
I think this is a problem with run_mode in CGI::Application. Here's what the script is supposed to do, and what it does:
What it's supposed to do:
Display a form. Supplicant enters data into form, including a filename, and clicks 'Upload.' Then it displays the values of field1 and field2. For the purpose of this test, it just ignores the value of the filename field.
What it actually does:
Display a form. After supplicant enters data and submits, it redisplays the same empty form.
It only misbehaves like this when the filename field is populated, and only with Firefox 1.5 on Win XP. And the real (full) script that actually does something with the file behaves the same way. Apparently the run_mode (rm) parameter is getting cleared when there is a file uploaded. So instead of going to save_mode and storing the file to the disk, it acts as if it got no input at all, and goes to the default mode, list_mode in this case.
Your most inferior servant has cut the code down to the minimum that reproduces this.
Question is, what in this code could be leading to this issue? Also, if anyone suspects this is a Firefox 1.5 on Win XP bug, do you have any suggestions for how to search out the real truth on this deep matter? We have several large prayer wheels standing by, powered by Makita 9V cordless drills with extra batteries donated by the Mill Valley Green Gulch Zen Center, ready to make thousands of revolutions on your behalf in return for any wisdom you would be willing to bestow.
Here's the wrapper code:
#!/usr/bin/perl -T use strict; use warnings; BEGIN { push @INC, "."; } use Min; my $minimal_uploader = Min->new(); $minimal_uploader->run();
And with our most humble obiences, here's where most of the action is:
#!/usr/bin/perl -T package Min; use base 'CGI::Application'; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use HTML::Template; use strict; use warnings; $ENV{'PATH'} = ''; sub setup { my $self = shift; $self->start_mode('list_mode'); $self->mode_param('rm'); $self->run_modes( 'list_mode' => \&list, 'save_mode' => \&save ); } sub list { my $self = shift; my $q = $self->query(); $q->param('rm', 'save_mode'); # hack? my $template = HTML::Template->new(filename => 'templates/test.tmp +l'); my $output = $q->b("Field1: ") . $q->textfield(-name=>'field1',-si +ze=>20) . $q->p() . $q->b("MP3:") . $q->filefield(-name=>'mymp3', -size=> +20) . $q->p() . $q->b("Field2:") . $q->textarea(-name=>'field2',-rows +=>4,-cols\ =>20); $output = $q->start_multipart_form() . $q->hidden(-name=>'rm',-value=>'save_mode') . $output . $q->br() . $q->submit(-label=>'Upload') . $q->end_form(); $template->param(LISTFORM => $output); return $template->output; } sub save { my $self = shift; my $q = $self->query(); my $field1 = $q->param('field1'); my $mp3 = $q->param('mymp3'); my $field2 = $q->param('field2'); # actual "SAVE" code has been deleted for this perlmonks post. # note this part does NOT use the template file # yes we aren't printing out the mp3 filename. # in the real code the file gets uploaded and saved # to disk, but not with Firefox 1.5 on Win XP. my $stuff; ($stuff = <<" END_STUFF")=~s/^\s+//gm; <html> <body> <p>field1 is $field1</p> <p>field2 is $field2</p> </html> END_STUFF return $stuff; } 1;
And here's a simple HTML::Template file being used for this test:
<html> <head> <title>testing</title> </head> <body> <TMPL_VAR NAME="LISTFORM"> </body> </html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Application and start_multipart_form stumper
by cees (Curate) on Dec 06, 2005 at 18:55 UTC | |
|
Re: CGI::Application and start_multipart_form stumper
by Belgarion (Chaplain) on Dec 06, 2005 at 05:13 UTC |