I simplified everything to the bare bones.  Nothing is getting passed.  I am
at a complete loss.  If anyone has a few minutes, just try running this.
You should be able to point it toward a text/plain file and have it
displayed below the file upload form.

No matter what I do, all I am seeing for content_type is:
CONTENT_TYPE: multipart/form-data;
boundary=---------------------------7d2fb231407ee

ie, nothing.

Here is the Apache config
PerlModule testUpload
<Location /testUpload>
  SetHandler perl-script
  PerlHandler testUpload
  PerlSendHeader Off
  # limit POSTS so that they get processed properly
  <Limit POST>
    PerlInitHandler POST2GET
  </Limit>
</Location>

Here is the code:
package testUpload;
use strict; 

our %results;
our %messages;

##############################
### START LOADING MODULES  ###
##############################
use Apache::Request ();

##############################
###         HANDLER        ###
##############################
sub handler{
        use Apache;
        use Apache::Constants qw(:common);

        my $r = shift;
        Apache->request($r);

        &main($r);
  
        return OK;
}

##############################
###  START OF MAIN LOGIC   ###
##############################
sub main{
        my $r = shift;
        my $q = Apache::Request->new($r, DISABLE_UPLOADS => 0, POST_MAX =>
20480000);

        my $cgi = CGI->new();
        #########################
        ##     START FORM      ##
        #########################
        $results{content} .= $cgi->start_multipart_form;
        $results{content} .= $cgi->filefield(-name=>'uploaded_file',
                            -default=>'starting value',
                            -size=>50,
                            -maxlength=>80);
        $results{content} .= $cgi->submit();
        $results{content} .= $cgi->endform;

        #########################
        ##  START UPLOAD FILE  ##
        #########################
        my $upload = $q->upload || undef;
        my $fh = ( defined($upload) ? $upload->fh : undef );
        $results{content} .= "Upload File<br />";
        if (defined( $fh )) {
                while (<$fh>) {
                        $results{content} .= $_;
                }
        }
        
        #########################
        ##     START DEBUG     ##
        #########################
        foreach my $var (sort keys %ENV) {
                push(@{$messages{debug}},(      "$var: $ENV{$var}" ))  if
($var =~ /content/i);
        }
        foreach my $var ($q->param) {
                push(@{$messages{debug}},(      "$var: ".$q->param($var) ))
if $var;
        }
        
        #########################
        ##    START MESSAGES   ##
        #########################
        # generate messages and/or errors if any
        foreach my $type (keys %messages) {
                my $status = join($cgi->p,@{$messages{$type}}) if
$messages{$type};
                $results{contenterrata} .= $status if $status;
        }
        
        #########################
        ##     START OUTPUT    ##
        #########################
        # send results to browser
        $r->send_http_header('text/html');
        print $cgi->start_html('File Upload Test');     
        print $cgi->h1('Content') . $results{content};
        print $cgi->h1('Errata') . $results{contenterrata};
        print $cgi->end_html();

        # clean up for mod_perl
        %results = ();
        %messages = ();
}

1;


   :  -----Original Message-----
   :  From: Issac Goldstand [mailto:[EMAIL PROTECTED]]
   :  Sent: Monday, March 18, 2002 9:37 AM
   :  To: Vuillemot, Ward W
   :  Cc: [EMAIL PROTECTED]
   :  Subject: Re: mod_perl does not see multipart POSTs
   :  
   :  
   :  I'm not sure I understand what you're asking...  Apache, 
   :  on it's own, 
   :  does not support any internal parsing of POST data, multipart or 
   :  otherwise, so why should mod_perl?  For this, we have the 
   :  Apache::Request library in mod_perl (Which is the 
   :  mod_perl interface to 
   :  the libapreq library for Apache's C API).  libapreq supports 
   :  multipart/form-data, even without a file upload...
   :  
   :   Issac
   :  
   :  Vuillemot, Ward W wrote:
   :  
   :  >All,
   :  >
   :  >I am still trying to figure out why my setup of mod_perl 
   :  does not have
   :  >multipart POSTs.  I rebooted my machine, and found that, 
   :  whereas I reported
   :  >before mod_perl would try to reload the page (which it 
   :  should not but send
   :  >out a text/plain attachment for download), it appears 
   :  the script (running as
   :  >a perl handler) does not see any of the multipart POST.  
   :  Vanilla posts are
   :  >not a problem, though.  Even if the information being 
   :  sent via multipart is
   :  >_not_ a file to upload to the server, the information is 
   :  lost in transit.
   :  >
   :  >Here is what is odd.  
   :  >
   :  >The same scripts/modules unmodified and running as 
   :  perl_cgi are okay.
   :  >Multipart forms allow me to upload files, et cetera.  In 
   :  short, I am
   :  >confident the problem is not with my programming.
   :  >
   :  >I am using the code snippet, POST2GET, to capture the 
   :  one-time read of POST
   :  >and storing as if it was retrieved via GET.
   :  >
   :  >Any ideas how to debug this?
   :  >
   :  >I REALLY REALLY would love some feedback.  I would love 
   :  to think that all my
   :  >effort to stay away from M$ ASP are worth it -- esp. 
   :  when I stand up to
   :  >defend Perl, Apache, and mod_perl in an environment that 
   :  is decidely
   :  >M$-bent.
   :  >
   :  >Thanks!
   :  >Ward
   :  >
   :  
   :  
   :  

Reply via email to