undef Upload object

2002-05-20 Thread Mike Melillo


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  3) {
   #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?




Re: undef Upload object

2002-05-20 Thread Geoffrey Young



Mike Melillo wrote:

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


[snip]



 sub upload {
 
 my ($r) = shift;
 my $apr = Apache::Request-new($r);
 my $status = $apr-parse;


you might want to check the status of that upload here first

   return $status unless $status == OK;

and look into

   $apr-notes(error-notes);

if it fails.


 my $upload = $apr-upload; 
 print STDERR Dumper($upload);
 my $size = $upload-size;
 if ($size  3) {


you can handle that condition with the POST_MAX parameter in new().


other than that, nothing jumps out at me.

we have a working example that may be able to help you some:

   http://www.modperlcookbook.org/code/ch03/Cookbook/PrintUploads.pm

HTH

--Geoff




Re: undef Upload object

2002-05-20 Thread Stas Bekman

Geoffrey Young wrote:
 
 
 Mike Melillo wrote:
 
 I am trying to have a user upload an image and I am getting an undef
 $apr-upload object.

 we have a working example that may be able to help you some:
 
   http://www.modperlcookbook.org/code/ch03/Cookbook/PrintUploads.pm

also see the new addition contributed by Rich Bowen:
http://perl.apache.org/release/docs/1.0/guide/snippets.html#File_Upload_with_Apache__Request

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com