Re: question on multipart forms and %fdat
Em Fri, 10 Jan 2003 00:32:55 +0900
Keith Watanabe <[EMAIL PROTECTED]> escreveu:
Hi,
Embperls handles file uploads trough CGI.pm this way when you use
"multipart" forms the file fields are converted in file handles.
In the code bellow it seems that your are reading from the wrong
variable in your object:
> sub upload
> {
> my $self = shift;
> my $file = "$self->{dest}/$self->{file}";
If in $self->{file} you have the "upload" field of the form you should
not use it here this way since it doen not contain just the filename.
In my code I apply the following regex (for a true portable solution you
should use File::Basename):
if ( $fdat{file} =~ /([^\/\\]+)$/ ) {
my $filename = $1;
$filename =~ s/^\.+//; # To prevent hidden files
}
> unlink $file if -e $file;
> open FILE, ">>$file" || die $!;
> my $buffer;
> my $totallength = 0;
> my $bytes;
> while( $bytes = read($self->{file}, $buffer, 1024) )
You have to be sure that in $self->{file} you are really reding from
a reference to $fdat{upload} since its there the magic with CGI.pm.
If you transformed the data it will not work since it will not be a
filehandle anymore. If you need to check and transform the "upload"
field to convert it in a filename you should store a reference to
$fdat{upload} in another instance variable of your object to read from
it later.
> {
> print FILE $buffer;
> $totallength += $bytes;
> }
> close FILE;
> close $self->{file};
> }
Regards,
Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Problems with $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
Hi list,
I am using ErrorDocument directive in apache and i set EMBPERL_OPTIONS 262144
My apache configuration is:
## MOD_PERL#Alias /perl /home/masilva/local/apache/cgi-bin/perlPerlModule Apache::Registry SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On allow from all
## EMBPERL#PerlModule HTML::EmbperlAddtype text/html .epl SetHandler perl-script PerlHandler HTML::Embperl Options ExecCGI
## EMBPERL /embperl/verdoc-des# SetHandler perl-script PerlHandler HTML::Embperl Options ExecCGI PerlSetEnv EMBPERL_OPTIONS 262144 ErrorDocument 500 http://merlin.cpqd.com.br:8082/embperl/verdoc-des/err.epl
## Apache::DBI#PerlModule Apache::DBI
But, when the err.epl is executed (by an die in some .epl), it stay slow and not return the page for browser. I can't get the error.
The @$errors storage the text of an "die" ?
The err.epl is:
[- $errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ; -] There are [+ scalar(@$errors) +] errormessages OIOI
Re: question on multipart forms and %fdat
Embperls handles file uploads trough CGI.pm this way when you use
"multipart" forms the file fields are converted in file handles.
In the code bellow it seems that your are reading from the wrong
variable in your object:
actually the thing is that the way my controller handles things, it doesn't
even make the upload call (because it relies on hidden fields that tells
other objects what to instantiate). The main problem i'm seeing is that
%fdat only returns " name" and " filename" keys back. If I have more than
one form field say hidden fields and text fields, those aren't
returned. Here's an example form i wrote up:
test
fdat: [+ %fdat +]
[$ foreach $item keys %fdat $]
item: "[+ $item +]" is "[+ $fdat{$item} +]"
[$ endforeach $]
When I attempt to iterate through %fdat, here's the type of output i receive:
fdat: 2/8
item: " name" is ""image""
item: " filename" is ""02071908max_NK116718_b.jpg" Content-Type: image/jpeg
ÿØÿà"
(where 02071908max_NK116718_b.jpg is the file upload I'm trying to deal
with). What I want to know is what happens to my other form info like
junk1, junk2, and junk3? When I remove the method="post" part, all of the
fields are displayed correctly. the expected output should've at least
included the hidden and text fields in addition to the file. i'm not
really sure what to make of this.
thanks!
-keith
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Re:Problems with $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
When i use [- $errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ; -]
the apache log: (stay in loop)
[Fri Jan 10 12:55:38 2003] [error] [29842]ERR: 24: Error in Perl code: Can't call method "pnotes" on an undefined value at /home/masilva/local/apache/htdocs/embperl/verdoc-des/err.epl line 8.
I am using Embperl 1.3.4, Apache/1.3.27 (Unix) mod_perl/1.27
Anybody know what is wrong ?
Thank you
De:
"Maurício Amorim " <[EMAIL PROTECTED]>
Para:
embperl <[EMAIL PROTECTED]>
Cópia:
Data:
Fri, 10 Jan 2003 14:00:41 +
Assunto:
Problems with $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
> Hi list,
>
> I am using ErrorDocument directive in apache and i set EMBPERL_OPTIONS 262144
>
> My apache configuration is:
>
> ## MOD_PERL#Alias /perl /home/masilva/local/apache/cgi-bin/perlPerlModule Apache::Registry SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On allow from all
> ## EMBPERL#PerlModule HTML::EmbperlAddtype text/html .epl SetHandler perl-script PerlHandler HTML::Embperl Options ExecCGI
> ## EMBPERL /embperl/verdoc-des# SetHandler perl-script PerlHandler HTML::Embperl Options ExecCGI PerlSetEnv EMBPERL_OPTIONS 262144 ErrorDocument 500 http://merlin.cpqd.com.br:8082/embperl/verdoc-des/err.epl
> ## Apache::DBI#PerlModule Apache::DBI
>
> But, when the err.epl is executed (by an die in some .epl), it stay slow and not return the page for browser. I can't get the error.
>
> The @$errors storage the text of an "die" ?
> The err.epl is:
>
>
[- $errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ; -] There are [+ scalar(@$errors) +] errormessages
OIOI
>
>
>
>
>
>
>
>
>
Esta mensagem foi verificada pelo E-mail Protegido Terra.Scan engine: VirusScan / Atualizado em 08/01/2003 / Versão: 1.3.13Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/
