package BusinessFormValidation; use base CGI::Application; use CGI::Application::ValidateRM; use Data::FormValidator; use CGI; $CGI::POST_MAX = 1536000; #$CGI::POST_MAX = 1536000; #~1.7MB use strict; print "Content-type: text/html\n\n "; sub setup { my $self = shift; $self->start_mode('form_display'); $self->run_modes([qw/ form_display form_process # data_process # upload_process /]); } sub form_display { my $self = shift; my $errs = shift; my $t = $self->load_tmpl('upload.tmpl',die_on_bad_params=>0); $t->param($errs) if ref $errs; return $t->output; } sub form_process { my $self = shift; my ($results,$err_page) = $self->check_rm('form_display', { required => [qw/ industry firstname lastname company address1 city us_states country zip_code ci_month ci_year p1 p2 p3 /], optional => [qw/ title province address2 f1 f2 f3 website zip_codex /], # dependencies => { # name1 => [ '2_name'], # }, constraints => { zip_code => 'zip', ci_email => 'email', }, # trim leading and trailing whitespace from all the val +id fields. filters => ['trim'], field_filters => { cc_no => "digit", zip_code => "digit", zip_codex => "digit", p1 => "digit", p2 => "digit", p3 => "digit", f1 => "digit", f2 => "digit", f3 => "digit", }, msgs=>{ any_errors => 'err__', prefix=>'err_', format => ' <b><font color="white" face="verdana" size +="1">*</font><font face="verdana" size="1">%s</font></b>', }, }); return $err_page if $err_page; #basic form elements are valid , upload validation/process: #foreach my $f ( $results->valid() ) { # print $f, " = ", $results->valid( $f ), "\n"; # } #prints out the form results. my $upload_dir = "C:/web site/uploads"; my $business_plan_file = $results->valid('file_name'); #upload f +iled name is file_name $business_plan_file =~ s/.*[\/\\](.*)/$1/; #retrieve filename +w/out full path my $upload_filehandle = $results->valid('file_name'); ## #my $content_type = $upload_filehandle->uploadInfo($business_plan_file +)->{'Content-Type'}; #print "hi"; if I uncomment this and the line above, the script will + somehow seem to die and will not print "hi" ## my $error = $upload_filehandle->error(); #this is where my main problem is being caused. Somehow its not retri +eving the error messages if the POST surpasses 1.7 mb. if ($error) { print "$error"; die; } #elsif { #my $content_type = $cgi->uploadInfo($business_plan_file)->{'Content-T +ype'}; #this will be placed if it passes the POST requirement length, then wi +ll check for specific MIME types allowed #} #this is the simple upload script I'm using, does this involve anythin +g whatsoever with the CGI.pm module? It seems like this code could +just be ran w/out "use CGI.pm" else { open UPLOADFILE, ">$upload_dir/$business_plan_file" || die; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; } } 1;
In reply to My Upload script, Am I even on the right track? by perleager
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |