Re: Re: libapreq2 upload question

[prev] [thread] [next] [Date index for 2004/12/19]

From: eps com estem
Subject: Re: Re: libapreq2 upload question
Date: 17:42 on 19 Dec 2004
Completing more my question:


---------------------------
PerlTransHandler +Blogum::BlogumURI
---------------------------
in httpd.conf


The html form, printed by javascript
---------------------------
..
var form_e =3D document.createElement('form');
form_e.setAttribute('ENCTYPE','multipart/form-data');
..
with several inputs (hidden, text and one "file")
---------------------------



The submit action is catched by BlogumURI.pm
---------------------------
..
} elsif ($uri =3D~ /$cri_newArticle/) { # URI is recognised
   my $url;
   Blogum::NewsArticle -> new_article($r,\$url);
   $uri =3D $1.$url;
   $redirected++;
   $apache->err_headers_out->{'Location'} =3D "$uri";
   }
..
$r->filename($r->document_root . $r->uri);
if ($redirected) {return Apache::HTTP_MOVED_TEMPORARILY;}
else  {return Apache::DECLINED;}
---------------------------


NewsArticle.pm "new_article" method calls News.pm that calls
---------------------------
$info =3D {};
$Generic -> info($info);
---------------------------


And finally, it is the info method that tries to parse the info (inside Generic.pm)
---------------------------
sub info {
   my ($self,$info) =3D @_;
   no warnings;
   my $apache_headers =3D$apache->headers_in;
   $info->{father} =3D$apache->hostname;
   $info->{file} =3D$apache->filename;
   $info->{name} =3D$apache_headers->{'Referer'};
   $info->{content} =3D$apache_headers->{'Content-Type'};
   if ($apache->method eq 'POST') {
      if ($info->{content} =3D~ /.*multipart.*/) {
         my $mm =3DApache::Request->new($apache,POST_MAX=3D>50000); #50k max
         my $uploads =3D$mm->upload();
         my $table =3D$mm->param(); #en teoria els uploads ja no estan
         warn $uploads.' '.%$uploads;
         warn $table.' '.%$table;
         foreach (keys %$uploads) {
            $uploads->{$_}->slurp(my $temp);
            warn 'IMAGE: '.$_.' - '.$uploads->{$_}.' ? '.$uploads->{$_}->name.' '.
            $uploads->{$_}->filename.' '.$uploads->{$_}->size.' '.$uploads->{$_}->type;
            }
         foreach (keys %$table){
            $info->{query} .=3D $_.'=3D'.$table->{$_}.'&';
            warn $_.' =3D '.$table->{$_};
            }
      } else {
         if ($apache_headers->{'Content-length'} < 10000000) {
            $apache ->read($info->{query},$apache_headers->{'Content-length'});
            }
         }
   } elsif ($apache->method eq 'GET') {
      $info->{query} =3D$apache->args;
      }
   $info->{ip} =3D$apache->connection->remote_ip();
   $info->{cookie} =3D$apache_headers->{'Cookie'};
   }
---------------------------
Now reading rightly the content-type (lapsus:) the caret is inside the multipart block.
($apache is $r and is a global var for all the package).

What i read in error.log is
---------------------------
Apache::Upload::Table=3DHASH(0x10dd168) 0 at f:\tools\apache2/lib/perl/Blogum/Generic.pm
line 207.
Apache::Request::Table=3DHASH(0x10dab5c) 6 at f:\tools\apache2/lib/perl/Blogum/Generic.pm
line 208.
user =3D l at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
subject =3D l at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
source =3D l at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
image =3D aaaUntitled-1.gif at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
directory =3D news_st at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
body =3D =F1li at f:\tools\apache2/lib/perl/Blogum/Generic.pm line 218.
---------------------------
(values of input are nonsense)

So i'm reading right the text values, but no news about my file (from which i have the
filename).

PD I've tried to be the clearest possible, and i also offer my sympathy :D.
Please i will put more code if you ask for.





-------------------------------------------




>"eps com estem" <a
href=3D"javascript:sendMsg('<ggerard@xxxxxxx.xxx>');"><ggerard@xxxxxxx.xxx></a> writes:
>> if ($apache->content_type() eq 'multipart/form-data') {
>No.  $r->content_type() represents the response (outgoing) header,
>not the request (incoming) header:
>   <a
href=3D"/app/message?l=3Des&o=3D8&url=3Dhttp%3A%2F%2Fperl%2Eapache%2Eorg%2Fdocs%2F2%2E0%2Fapi%2FApache%2FRequestRec%2Ehtml%23C%5Fcontent%5Ftype%5F"
target=3D"_blank">http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_content_type_</a>;
>>
>> While i'm able to read all text params, there are no entries in $uploads.
>No clue.  I'd like to help, but puzzling out the problem 
>from your code snippets isn't sufficient enticement.  Please 
>post full details, including a complete package+handler with 
>configuration info and error-log output.  Maybe it's an apreq 
>bug, maybe it isn't.  But if I can't reproduce your problem 
>locally, there's not much I can do other than offer you my 
>sympathy.
>-- 
>Joe Schaefer
---------------------------------------------------------
Esta Navidad, sé más original ¿Te atreves a enviar una postal con tu voz? http://greetingmania.ya.com
Ya.com ADSL Router Wi-Fi: Sólo 29,90 €/mes + IVA*. Router + Antivirus y firewall ¡Gratis! http://acceso.ya.com/adsl/256router

        -- 
        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: Re: libapreq2 upload question
eps com estem 17:42 on 19 Dec 2004

Re: libapreq2 upload question
Joe Schaefer 20:34 on 19 Dec 2004

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52