You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Udlei Nattis <ma...@anankeit.com.br> on 2003/04/01 19:14:27 UTC

[mp2] upload file

hi,

i have problem for upload files
testing use CGI and CGI::Simple

look file.pm:

    $cgi = CGI->new;
    $r->print($cgi->param("test")." xxx ");

file .html

<form action="end" method="post" enctype="multipart/form-data">
<input type="file" name="image">
<input type="hidden" name="test" value="abcdef">
<input type="submit">
</form>

when i add enctype param("test") return undefined value
and wne i remove enctype param("test") print "abcdef"

my question is: why when i add enctype, param("test") return undefined 
value?

sorry my english ;)

thanks


Re: [mp2] upload file

Posted by Stas Bekman <st...@stason.org>.
Udlei Nattis wrote:
> fix problem
> 
> i need change SetHandler modperl to perl-script, now upload is ok
> 
> why this happens? i need add any options in SetHandler modperl to use 
> upload ?

Please read:
http://perl.apache.org/docs/2.0/user/config/config.html#C_SetHandler_

Do you say that you have no errors logged in error_log while using 'SetHandler 
modperl'? You should, because Apache->request dies if called under 'SetHandler 
modperl' and no 'PerlOptions +GlobalRequest'

I can see why the env reading was failing. We need to patch CGI.pm to die when 
  the configuration is:

   PerlOptions -SetupEnv

(which is effective with 'SetHandler modperl'), though we don't have the API 
to do so yet. Once I'll finish the filter API, I'll work on the perloptions 
API and then we will patch CGI.pm to do this check.

Meanwhile I believe CGI.pm can be patched to check for some cgi env var (e.g. 
$ENV{QUERY_STRING}) and if it's not there run $r->subprocess_env, which is in 
effect the same as 'PerlOptions +SetupEnv'. Can you give a try to this while 
keeping the setting 'SetHandler modperl':

# CGI.pm
sub new {
     my($class,$initializer) = @_;
     my $self = {};
     bless $self,ref $class || $class || $DefaultClass;
     if ($MOD_PERL) {
         my $r = Apache->request;
         if ($MOD_PERL == 1) {
             $r->register_cleanup(\&CGI::_reset_globals);
         }
         else {
             # PerlOptions -SetupEnv check
             # XXX: this should be really replaced with a check
             # of the SetupEnv perloptions check, once the API is available
             $r->subprocess_env unless exists $ENV{QUERY_STRING};
             $r->pool->cleanup_register(\&CGI::_reset_globals);
         }
         undef $NPH;
     }
     $self->_reset_globals if $PERLEX;
     $self->init($initializer);
     return $self;
}

the change is:

   $r->subprocess_env unless exists $ENV{QUERY_STRING};

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: [mp2] upload file

Posted by Udlei Nattis <ma...@anankeit.com.br>.
fix problem

i need change SetHandler modperl to perl-script, now upload is ok

why this happens? i need add any options in SetHandler modperl to use 
upload ?

thanks

nattis

Stas Bekman wrote:

>> I used of examples these 2 archives
>> but dont functioned
>>
>> in mp1 i dont have problem
>>
>> my mp2 version is last cvs version
>
>
> So you have a problem with mp2. Did you upgrade your CGI.pm to the 
> latest version?
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
>
>



Re: [mp2] upload file

Posted by Stas Bekman <st...@stason.org>.
> I used of examples these 2 archives
> but dont functioned
> 
> in mp1 i dont have problem
> 
> my mp2 version is last cvs version

So you have a problem with mp2. Did you upgrade your CGI.pm to the latest version?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: [mp2] upload file

Posted by Udlei Nattis <ma...@anankeit.com.br>.
Hi Stas

I used of examples these 2 archives
but dont functioned

in mp1 i dont have problem

my mp2 version is last cvs version

thanks

nattis

Stas Bekman wrote:

> Udlei Nattis wrote:
>
>> hi,
>>
>> i have problem for upload files
>> testing use CGI and CGI::Simple
>>
>> look file.pm:
>>
>>    $cgi = CGI->new;
>>    $r->print($cgi->param("test")." xxx ");
>>
>> file .html
>>
>> <form action="end" method="post" enctype="multipart/form-data">
>> <input type="file" name="image">
>> <input type="hidden" name="test" value="abcdef">
>> <input type="submit">
>> </form>
>>
>> when i add enctype param("test") return undefined value
>> and wne i remove enctype param("test") print "abcdef"
>>
>> my question is: why when i add enctype, param("test") return 
>> undefined value?
>
>
> Does the same program works with mp1? Do you use the latest mp2 (at 
> least 1.99_08), better cvs?
>
> The 2.0 test suite has an upload file test (CGI.pm) and it works fine 
> with the current mod_perl. Please look at the pair:
> t/modules/cgiupload.t
> t/response/TestModules/cgiupload.pm
> in the mod_perl source.
>
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
>
>



Re: [mp2] upload file

Posted by Stas Bekman <st...@stason.org>.
Udlei Nattis wrote:
> hi,
> 
> i have problem for upload files
> testing use CGI and CGI::Simple
> 
> look file.pm:
> 
>    $cgi = CGI->new;
>    $r->print($cgi->param("test")." xxx ");
> 
> file .html
> 
> <form action="end" method="post" enctype="multipart/form-data">
> <input type="file" name="image">
> <input type="hidden" name="test" value="abcdef">
> <input type="submit">
> </form>
> 
> when i add enctype param("test") return undefined value
> and wne i remove enctype param("test") print "abcdef"
> 
> my question is: why when i add enctype, param("test") return undefined 
> value?

Does the same program works with mp1? Do you use the latest mp2 (at least 
1.99_08), better cvs?

The 2.0 test suite has an upload file test (CGI.pm) and it works fine with the 
current mod_perl. Please look at the pair:
t/modules/cgiupload.t
t/response/TestModules/cgiupload.pm
in the mod_perl source.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com