Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I could have sworn I knew how this worked, but apparently I was wrong. I am uploading a file via CGI.pm, and I wish to test if the file exists or if a garbage filename was entered
Here are two scripts that demonstrate the problem. The first just creates a filefield, the second is supposed to test if a real file was entered. If I use a POST method for the form, no error-checking is performed. If I use a GET method, however, the error-checking is activated.
Any idea why this is happening, and how to determine when to GET and when to POST?
part1.cgi
use CGI qw/:standard/; use strict; my $cgi = new CGI; print $cgi->header(), $cgi->start_html(), $cgi->start_multipart_form({ -method => 'GET', -action => 'part2.cgi' }), $cgi->filefield({ -name => 'filename', }), $cgi->submit('Add'), $cgi->end_form(), $cgi->end_html();
part2.cgi
use CGI qw/:standard/; use strict; my $cgi = new CGI; print $cgi->header(), $cgi->start_html(); if (!upload('filename')) { print "We Die"; } else { print "No Die"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get vs. POST in CGI.pm
by chromatic (Archbishop) on Sep 22, 2003 at 20:12 UTC | |
by Anonymous Monk on Sep 22, 2003 at 21:40 UTC | |
by LazerRed (Pilgrim) on Sep 22, 2003 at 23:52 UTC | |
by iburrell (Chaplain) on Sep 23, 2003 at 17:11 UTC | |
by Anonymous Monk on Sep 24, 2003 at 01:50 UTC | |
|
Re: Get vs. POST in CGI.pm
by LazerRed (Pilgrim) on Sep 22, 2003 at 20:29 UTC | |
|
Re: Get vs. POST in CGI.pm
by Hagbone (Monk) on Sep 22, 2003 at 23:26 UTC | |
by Anonymous Monk on Sep 24, 2003 at 01:57 UTC | |
|
Re: Get vs. POST in CGI.pm
by shenme (Priest) on Sep 23, 2003 at 04:48 UTC | |
by Anonymous Monk on Sep 24, 2003 at 02:00 UTC |