Re: Problem with modperl2/apache2/apreq2 upload

2004-04-23 Thread Ken Burcham
This is fixed for me now.  I got the latest stuff from cvs and 
the list context array returns just the fields that are upload 
fields.

Thanks SO much!

ken.

On 11 Apr 2004 at 20:51, Joe Schaefer <[EMAIL PROTECTED] wrote:

> Any news?  Happy Easter.
> 
> ken.
> 
> On 8 Apr 2004 at 13:22, Joe Schaefer wrote:
> 
> > "Ken Burcham" <[EMAIL PROTECTED]> writes:
> > 
> > [...]
> > 
> > > foreach my $key (keys %{$uploads})
> > > {
> > >warn "Uploader found $key";
> > > 
> > >my $upload = $uploads->{$key};
> > > 
> > >warn "Found $upload->filename";
> > > 
> > > }
> > 
> > [...]
> > 
> > > But nothing else as if my foreach finds nothing...  What am I 
> > > missing?  :) 
> > 
> > No clue at the moment-  foreach(keys %$uploads) should loop once
> > for the upload file.  I'll look into that problem also.
> > 
> > [...]
> > 
> > > warn "There was a problem uploading: $uploadfile" unless $upload-
> > > >link($uploadfile);
> > > 
> > > Am I on the right track with this?  It fails...  In another 
> > > thread (http://www.gossamer-
> > > threads.com/archive/mod_perl_C1/modperl_F7/File_uploads_using_Apa
> > > che:%3Brequest_in_mod_perl2_P101676), you mention 3 possibilities 
> > > as to why it could fail and it implicates a temp directory...  
> > 
> > Yes, your problem with link() is likely the temp dir location.
> > That problem is resolved in current cvs, and with the patch I 
> > posted on that thread.
> > 
> > > 
> > > 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?  
> > 
> > No, link() will do it for you; use current cvs or apply the patch.
> > 
> > -- 
> > Joe Schaefer
> > 
> > 
> > -- 
> > Report problems: http://perl.apache.org/bugs/
> > Mail list info: http://perl.apache.org/maillist/modperl.html
> > List etiquette: http://perl.apache.org/maillist/email-etiquette.html
> 
> 

-- 
Ken Burcham
Ken Burcham Consulting, Inc.
http://www.capemaystation.com



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Joe Schaefer
"Ken Burcham" <[EMAIL PROTECTED]> writes:

[...]

> foreach my $key (keys %{$uploads})
> {
>warn "Uploader found $key";
> 
>my $upload = $uploads->{$key};
> 
>warn "Found $upload->filename";
> 
> }

[...]

> But nothing else as if my foreach finds nothing...  What am I 
> missing?  :) 

No clue at the moment-  foreach(keys %$uploads) should loop once
for the upload file.  I'll look into that problem also.

[...]

> warn "There was a problem uploading: $uploadfile" unless $upload-
> >link($uploadfile);
> 
> Am I on the right track with this?  It fails...  In another 
> thread (http://www.gossamer-
> threads.com/archive/mod_perl_C1/modperl_F7/File_uploads_using_Apa
> che:%3Brequest_in_mod_perl2_P101676), you mention 3 possibilities 
> as to why it could fail and it implicates a temp directory...  

Yes, your problem with link() is likely the temp dir location.
That problem is resolved in current cvs, and with the patch I 
posted on that thread.

> 
> 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?  

No, link() will do it for you; use current cvs or apply the patch.

-- 
Joe Schaefer


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Ken Burcham
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:

http://search.cpan.org/~stas/mod_perl-1.99_13/docs/api/APR/Table.pod

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-
>link($uploadfile);

Am I on the right track with this?  It fails...  In another 
thread (http://www.gossamer-
threads.com/archive/mod_perl_C1/modperl_F7/File_uploads_using_Apa
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?  

thanks!

ken.


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

> "Ken Burcham" <[EMAIL PROTECTED]> 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: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html

-- 
Ken Burcham
Ken Burcham Consulting, Inc.
http://www.capemaystation.com



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Joe Schaefer
"Ken Burcham" <[EMAIL PROTECTED]> 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: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Ken Burcham



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;


if(@uploads)
{
  warn "Got an UPLOAD Array: ". scalar @uploads;
  $context->uploadsarray([EMAIL PROTECTED]);


  foreach my $uploadfilename (@uploads)
  {
#my $upload = $q->upload($uploadfilename); 
#SEGFAULTS!
if ($uploadfilename eq 'resourceurl')
{
  my 
$upload = $q->upload($uploadfilename); # DOESN'T SEFAULT!
      warn 
"UPLOADER FILENAME: ".$upload->filename;
      warn 
"UPLOADER found $uploadfilename ";


    }
else
    {
  warn 
"UPLOADER FOUND BOGUS PARM: $uploadfilename";
    }
  }
}






Here's the results:


Got an UPLOAD Array: 24 at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 89.
UPLOADER FOUND BOGUS PARM: sys_community at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 
104.
UPLOADER FOUND BOGUS PARM: sys_name at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: name at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: keywords at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: author at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: contact at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: title at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: summary at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: msgmoderator at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 
104.
UPLOADER FOUND BOGUS PARM: status at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: datecreated at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 
104.
UPLOADER FOUND BOGUS PARM: effectivedate at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 
104.
UPLOADER FOUND BOGUS PARM: expirationdate at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 
104.
UPLOADER FOUND BOGUS PARM: modby at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FILENAME: G:\projects\gcx\temp\navSub_bullet_grey.gif at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm 
line 99.
UPLOADER found resourceurl  at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 100.
UPLOADER FOUND BOGUS PARM: language-dropdown at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm 
line 104.
UPLOADER FOUND BOGUS PARM: quality at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: version at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: downloads at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: source at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: uploader at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: parentid at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.
UPLOADER FOUND BOGUS PARM: resourcetype-dropdown at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm 
line 104.
UPLOADER FOUND BOGUS PARM: sys_action at /usr/lib/perl5/site_perl/5.8.0/GCX/Runtime/Input/Handler.pm line 104.





Here's my segfault:


 child pid 6758 exit signal Segmentation fault (11)


And I rebuilt mod_perl2 with MP_DEBUG=1 but I don't see a core 
anywhere?  Where would I look? 

ken.




On 8 Apr 2004 at 10:18, Ken Burcham wrote:


> Joe: Thanks so much for taking the time to answer...
> 
> I'll look into the segfault backtrace next...
> 
> When I do this:
> 
>  my $q = Apache::Request->new($r);
>  my @uploads = $q->upload;
> 
>  warn 'Number of uploads: '. scalar @uploads;
> 
>  foreach my $uploadfilename (@$uploads)
>  {
> #my $upload = $q->upload($uploadfilename); #SEGFAULTS!
> warn "UPLOADER found " . $uploadfilename;
>  }
> 
> I get "Number of uploads: 24" which is the number of fields on my 
> multipart html form of which only one is a "file" type:
> 
> 
> name="resourceform" parent="resourceform">
> ...
> 
> 
> 
> length="" max="">
> 
> 
> 
> 
> length="" max="">
> 
> 
> 
> 
> max="">
> 
> 
> 
> 
> max="">
> 
> ...
> 
> 
> In my apache error log I see:
> 
> .

(Fwd) Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Ken Burcham
Joe: Thanks so much for taking the time to answer...

I'll look into the segfault backtrace next...

When I do this:

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

 warn 'Number of uploads: '. scalar @uploads;

 foreach my $uploadfilename (@$uploads)
 {
#my $upload = $q->upload($uploadfilename); #SEGFAULTS!
warn "UPLOADER found " . $uploadfilename;
 }

I get "Number of uploads: 24" which is the number of fields on my 
multipart html form of which only one is a "file" type:


...

effective date



expiration date



moderated by



resource url


...


In my apache error log I see:

...
UPLOADER found effectivedate  at (eval 20) line 14.
UPLOADER found expirationdate  at (eval 20) line 14.
UPLOADER found modby  at (eval 20) line 14.
UPLOADER found resourceurl  at (eval 20) line 14.
...


So it looks to me like EVERY field gets dumped into the upload 
array...  Like I said, I'm probably doing something stupid...  

I'll look into the backtrace now...

THANKS so much!

ken.




On 8 Apr 2004 at 9:18, Joe Schaefer wrote:

> "Ken Burcham" <[EMAIL PROTECTED]> writes:
> 
> > > That's certainly supposed to work, assuming 'somefilename' is
> > > the name of the upload widget in your HTML form. Can you post 
> > > a backtrace for the segfault?
> > 
> > Sure... umm... how do I do that?  :)
> > 
> > I'm still pretty new to perl.  
> 
> Segfaults arise from buggy C code. For instructions on generating
> a backtrace, read
> 
>   http://perl.apache.org/docs/2.0/user/help/help.html#Resolving_Segmentation_Faults
> 
> > > 
> > > That is correct.  In apache1 the uploads formed a linked list
> > > internally, but that's no longer true in apreq2. In apreq2 
> > > $req->upload follows the same interface pattern as $req->param.
> > 
> > How do I get to just the upload items?  Or do I test via $upload-
> > >info/type?
> 
> 
>   No need to test anything: $req->upload() works just like 
> $req->param(), but it is restricted to uploads only.  For example
> 
>   my $upload_table_ref = $req->upload; # APR::Table ref of uploads
> 
>   foreach my $name (keys %$upload_table_ref) {
>  my @uploads = $req->upload($name); # Array of Apache::Upload
> # objects having name = $name
>  # do something with @uploads
>   }
> 
> -- 
> Joe Schaefer
> 
> 
> -- 
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html


--- End of forwarded message - 
Ken Burcham
Ken Burcham Consulting, Inc.
http://www.capemaystation.com



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-08 Thread Joe Schaefer
"Ken Burcham" <[EMAIL PROTECTED]> writes:

> > That's certainly supposed to work, assuming 'somefilename' is
> > the name of the upload widget in your HTML form. Can you post 
> > a backtrace for the segfault?
> 
> Sure... umm... how do I do that?  :)
> 
> I'm still pretty new to perl.  

Segfaults arise from buggy C code. For instructions on generating
a backtrace, read

  http://perl.apache.org/docs/2.0/user/help/help.html#Resolving_Segmentation_Faults

> > 
> > That is correct.  In apache1 the uploads formed a linked list
> > internally, but that's no longer true in apreq2. In apreq2 
> > $req->upload follows the same interface pattern as $req->param.
> 
> How do I get to just the upload items?  Or do I test via $upload-
> >info/type?


  No need to test anything: $req->upload() works just like 
$req->param(), but it is restricted to uploads only.  For example

  my $upload_table_ref = $req->upload; # APR::Table ref of uploads

  foreach my $name (keys %$upload_table_ref) {
 my @uploads = $req->upload($name); # Array of Apache::Upload
# objects having name = $name
 # do something with @uploads
  }

-- 
Joe Schaefer


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: Problem with modperl2/apache2/apreq2 upload

2004-04-07 Thread Ken Burcham



> That's certainly supposed to work, assuming 'somefilename' is
> the name of the upload widget in your HTML form. Can you post 
> a backtrace for the segfault?


Sure... umm... how do I do that?  :)

I'm still pretty new to perl.  

> 
> That is correct.  In apache1 the uploads formed a linked list
> internally, but that's no longer true in apreq2. In apreq2 
> $req->upload follows the same interface pattern as $req->param.


How do I get to just the upload items?  Or do I test via $upload-
>info/type?


thanks a lot,


ken.




On 7 Apr 2004 at 22:33, Joe Schaefer wrote:


> "Ken Burcham" <[EMAIL PROTECTED]> writes:
> 
> >   I've been reading and trying things all day to no avail which 
> > usually means I'm doing something stupid.  I have a perl apache 
> > module running under Apache 2.0.48/Mod_perl 
> > 1.99_13/libapreq2.02_02 and I'm trying to take a file upload.  
> > 
> >   I'm getting a segfault whenever I call $req->upload with a 
> > parameter:
> > 
> > my $upload = $req->upload('somefilename');
> 
> That's certainly supposed to work, assuming 'somefilename' is
> the name of the upload widget in your HTML form. Can you post 
> a backtrace for the segfault?
> 
> > I can, however, call: my @uploads = $req->upload; and it returns 
> > to me an array of parm names.  In apache1, a call to ->upload 
> > would return to me just upload objects whereas in apache2 it is 
> > apparently returning every param name on the form.  Is that 
> > right?
> 
> That is correct.  In apache1 the uploads formed a linked list
> internally, but that's no longer true in apreq2. In apreq2 
> $req->upload follows the same interface pattern as $req->param.
> 
> -- 
> Joe Schaefer
> 
> 
> -- 
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html



-- 
Ken Burcham
Ken Burcham Consulting, Inc.
http://www.capemaystation.com




Re: Problem with modperl2/apache2/apreq2 upload

2004-04-07 Thread Joe Schaefer
"Ken Burcham" <[EMAIL PROTECTED]> writes:

>   I've been reading and trying things all day to no avail which 
> usually means I'm doing something stupid.  I have a perl apache 
> module running under Apache 2.0.48/Mod_perl 
> 1.99_13/libapreq2.02_02 and I'm trying to take a file upload.  
> 
>   I'm getting a segfault whenever I call $req->upload with a 
> parameter:
> 
> my $upload = $req->upload('somefilename');

That's certainly supposed to work, assuming 'somefilename' is
the name of the upload widget in your HTML form. Can you post 
a backtrace for the segfault?

> I can, however, call: my @uploads = $req->upload; and it returns 
> to me an array of parm names.  In apache1, a call to ->upload 
> would return to me just upload objects whereas in apache2 it is 
> apparently returning every param name on the form.  Is that 
> right?

That is correct.  In apache1 the uploads formed a linked list
internally, but that's no longer true in apreq2. In apreq2 
$req->upload follows the same interface pattern as $req->param.

-- 
Joe Schaefer


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Problem with modperl2/apache2/apreq2 upload

2004-04-07 Thread Ken Burcham



Guruiers,


  I've been reading and trying things all day to no avail which 
usually means I'm doing something stupid.  I have a perl apache 
module running under Apache 2.0.48/Mod_perl 
1.99_13/libapreq2.02_02 and I'm trying to take a file upload.  


  I'm getting a segfault whenever I call $req->upload with a 
parameter:


my $upload = $req->upload('somefilename');


I can, however, call: my @uploads = $req->upload; and it returns 
to me an array of parm names.  In apache1, a call to ->upload 
would return to me just upload objects whereas in apache2 it is 
apparently returning every param name on the form.  Is that 
right?


So how can I get just those params that are upload objects?  I'd 
really like to be able to use apache2 and not revert to cgi since 
I had it working so nicely in apache1...


thanks,


ken.





-- 
Ken Burcham
Ken Burcham Consulting, Inc.
http://www.capemaystation.com