Skip Menu |

This queue is for tickets about the CGI-Simple CPAN distribution.

Report information
The Basics
Id: 8497
Status: resolved
Priority: 0/
Queue: CGI-Simple

People
Owner: Nobody in particular
Requestors: steve [...] purkis.ca
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.075
Fixed in: (no value)



Subject: [REQ] no error when $cgi->upload() used to test for existence of uploads
Hi, I'm testing to see if a file was uploaded using CGI::Simple's upload() method in this fashion: return process_upload( $cgi ) if ($cgi->upload and !$cgi->cgi_error); return handle_cgi_upload_error( $cgi ) if ($cgi->cgi_error); Unfortunately upload() sets cgi_error() if the user hasn't uploaded anything yet, which wipes out any other errors that may have happened, and causes my code to report an error that isn't really an error (yes, I realize I can get around this). This behaviour isn't intuitive... the problem is here: sub upload { ... unless ($ENV{'CONTENT_TYPE'} =~ m|^multipart/form-data|i) { $self->cgi_error('Oops! File uploads only work if you specify ENCTYPE="multipart/form-data" in your <FORM> tag'); return undef; } ... It would make more sense to me if that error was *not* set right off the bat -- I'm only testing to see if the upload occured yet, and I'd rather not have to parse $ENV{CONTENT_TYPE} to figure that out (that's CGI::Simple's job - which is why I'm using it ;-). Instead, I suggest upload() throws an error only if the user is trying to access an uploaded file. -Steve
Fixed, error now thrown later. [SPURKIS - Wed Nov 17 07:06:18 2004]: Show quoted text
> Hi, > > I'm testing to see if a file was uploaded using CGI::Simple's upload() > method in this fashion: > > return process_upload( $cgi ) if ($cgi->upload and !$cgi-
> >cgi_error);
> return handle_cgi_upload_error( $cgi ) if ($cgi->cgi_error); > > Unfortunately upload() sets cgi_error() if the user hasn't uploaded > anything yet, which wipes out any other errors that may have > happened, and causes my code to report an error that isn't really > an error (yes, I realize I can get around this). > > This behaviour isn't intuitive... the problem is here: > > sub upload { > ... > unless ($ENV{'CONTENT_TYPE'} =~ m|^multipart/form-data|i) { > $self->cgi_error('Oops! File uploads only work if you specify > ENCTYPE="multipart/form-data" in your <FORM> tag'); > return undef; > } > ... > > It would make more sense to me if that error was *not* set right off > the bat -- I'm only testing to see if the upload occured yet, and > I'd rather not have to parse $ENV{CONTENT_TYPE} to figure that out > (that's CGI::Simple's job - which is why I'm using it ;-). > > Instead, I suggest upload() throws an error only if the user is trying > to access an uploaded file. > > -Steve