I am trying to have a user upload an image and I am getting an undef
$apr->upload object.

Here is the code:


<form method="post" ENCTYPE="multipart/form-data" action="/join">
<input type=hidden name=action value=upload>
<br>
your picture (size limit: 30k)<br>
<input type=file name=userpic size=20>
<p>
<input type=submit name="submit" value="ADD PROFILE">
</form>




sub upload {

        my ($r) = shift;
        my $apr = Apache::Request->new($r);
        my $status = $apr->parse;
        my $upload = $apr->upload; 
        print STDERR Dumper($upload);
        my $size = $upload->size;
        if ($size > 30000) {
           #file is too big
           warn("File is too big\n");   
           return SERVER_ERROR;
        }  

        my $type = $upload->type;
        if ($type ne 'image/jpeg') {
           # not a jpeg
           warn("Not a jpeg\n");
           return SERVER_ERROR;
        }
        my $fh = $upload->fh;
        my $filename = $upload->filename;

         $apr->send_http_header( 'text/html' );
        $apr->print("hello file\n");
        return OK;

} # end of upload


The upload subroutine is still in the debugging stages hence the return
SERVER_ERROR and warn'ings.    The Date::Dumper prints $VAR1 = undef;

Ideas?

Reply via email to