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"; }
In reply to Get vs. POST in CGI.pm by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |