perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Burcham" <>
Subject Re: Problem with modperl2/apache2/apreq2 upload
Date Thu, 08 Apr 2004 17:02:54 GMT
I tried as you suggested and here's what I have:

my $q = Apache::Request->new($r);

my $uploads = $q->upload;  

my @arrayups = $q->upload;

warn "There's an array of scalars: ". scalar @arrayups;
warn "and I have a table ref: ".$uploads;

foreach my $key (keys %{$uploads})
       warn "Uploader found $key";

       my $upload = $uploads->{$key};

	 warn "Found $upload->filename";


and this is what I get:

There's an array of scalars: 24 at (eval 20) line 8.
and I have a table ref: Apache::Upload::Table=HASH(0x8222cdc) at 
(eval 20) line 9.

But nothing else as if my foreach finds nothing...  What am I 
missing?  :)  I'm looking at last example in the synopsis of:

also, when I finally do get it (by cheating and calling $q-
>upload('resourceurl') directly) I'm trying to link using this:

my $filename = $upload->filename;
#my $upload_filehandle = $upload->fh;
$filename =~ s/.*[\/\\](.*)/$1/;
warn "filename:". $filename;
my $upload_dir = $sysparms->{uploaddirectory};
my $uploadfile = "$upload_dir/$filename";

warn "There was a problem uploading: $uploadfile" unless $upload-

Am I on the right track with this?  It fails...  In another 
thread (http://www.gossamer-
che:%3Brequest_in_mod_perl2_P101676), you mention 3 possibilities 
as to why it could fail and it implicates a temp directory...  

I'm expecting it to write to that file.  The $upload_dir exists, 
but the file obviously doesn't because I'm trying to upload it...  

Do I need to ->bb and then write it?  



On 8 Apr 2004 at 10:56, Joe Schaefer wrote:

> "Ken Burcham" <> writes:
> > Ok, I might be on to something...
> > 
> > I think the segfault is coming when I call 'upload' with a non-
> > upload field...  But since calling 'upload' without a name 
> > returns to me a list of variable names that include non-upload 
> > fields, iterating through guarantees me to segfault:
> > 
> > (NOTE: resourceurl is the only 'file' field on my form with 23 
> > other 'text' fields)
> > 
> > my $q = Apache::Request->new($r);
> > 
> > my @uploads = $q->upload;
> OK, I see the problem now.  In list context $q->upload()
> is failing to filter out the non-upload keys.  It should 
> get fixed in the next release, but in the meantime try 
> using $q->upload() in scalar context. That will give you 
> an Apache::Upload::Table (@ISA=APR::Table) to work with.
> The table will only contain uploads, and since it's a 
> tied hash, you can iterate over it using keys() or each().
> -- 
> Joe Schaefer
> -- 
> Report problems:
> Mail list info:
> List etiquette:

Ken Burcham
Ken Burcham Consulting, Inc.

Report problems:
Mail list info:
List etiquette:

View raw message