I've been attempting to write a perl module that handles POSTs of type
multipart/form-data, and have been having a rough time.

I'm using Apache::Request to process the request.  I have dumped the
content-type of the incoming request, and verified that it's
"multipart/form-data".  I can use param() to get the parameters, but I can't
seem to use upload() to access the blocks directly.

I've included the code from my test handler below.  Basically it attempts to
access a large parameter MIME block two ways - using param() and using
upload().  The param() version works fine, but the upload() version can't
find the block.

Any clues?  The only thing that I can think of is that for this test case,
the MIME type of the "message" block is text/plain (it's in a TEXTAREA
field, for testing purposes).  Is it possible that Apache::Request will not
allow me to process "normal" form fields with upload()?

-jse


sub handler
{
    my $r = shift;
    my $apr = Apache::Request->new($r);
    my $block;
    my $buffer;

    $r->content_type('text/html');
    $r->send_http_header();

    $buffer = $apr->param('message');
    $r->print("<b>Message:</b><br><pre>$buffer</pre><br>");

    $block = $apr->upload('message');
    if ($block)
    {
        $r->print("Found message");
    }
    else
    {
        $r->print("No message");
    }

    return OK;
}

Reply via email to