On Tue, 21 May 2002, Mike Melillo wrote:
Hey, Mikey!
> Date: Tue, 21 May 2002 23:28:29 -0400
> From: Mike Melillo <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Image::Size, TT, and mod_perl Question
>
>
>
> I posed this question to the Template Toolkit list and got no response,
> so I figured I'd give this list a shot...
>
>
> ---------------------
>
> Hello, below is some code I have in a mod_perl handler that checks to
> see if an uploaded image is less than 300 pixels tall or wide.
> Everything seems to be working except the fact that the template is not
> returning with the proper values processed. Below is the code and the
> err_log output when I output an image that is too wide.
>
>
> [snip]
> my $upload = $r->upload;
> my $type = $upload->type;
> my $fh = $upload->fh;
> my $username = $r->param('username');
>
>
> my ($x, $y) = imgsize($fh);
> print STDERR Dumper($x);
> print STDERR Dumper($y);
>
> unless ($x < 300) {
> print STDERR "the greater than works\n";
> # This checks to make sure the image isnt more than 300 x 300
> my %vars = {TOO_WIDE => 1};
You're creating the hash incorrectly. Do either:
my %vars = ( TOO_WIDE => 1 );
or
my $vars = { TOO_WIDE => 1 };
ky
> my $config = {
> INCLUDE_PATH => '/moc/html/templates',
> POST_CHOMP => 1,
> EVAL_PERL => 1,
> };
>
> my $template = Template->new($config) || die "New Template Failed:
> $!\n";
>
> #the process method prints the template out to the browser via
> $r
> $template->process('pic_upload.tt2', \%vars, $r) || do {
> $r->log_reason($template->error());
> return SERVER_ERROR;
> };
> return OK;
>
> } # end of X/Y coordinate if
>
> [snip]
>
> The err_log output:
>
> $VAR1 = 310;
> $VAR1 = 72;
> the greater than works
>
> [end of err_log]
>
> The problem is the template pic_upload.tt2 has this in it:
>
> [% IF TOO_WIDE %]
> <font color=red>Your File was too big. Make it under 30K</font><p> [%
> END %]
>
> But that isn't showing up. I do the almost identical thing immediately
> after this if clauses to check if the file's type is a jpeg. That
> works, so I don't understand what I pasted in wrong, or forgot to paste
> in.
>
> Mike
>
>
>
>
--
# -----------------------------
# k e n Ken Y. Clark
# r y [EMAIL PROTECTED]
# a l c 972-542-7923
# -----------------------------