Hi folks,
What I'm trying to do is write a CGI script that will later
be referenced by a javascript sniglet to load a random
image from an inventory of images in a set directory.
The random selection part is working just fine, but what
is driving me crazy is the part where we send the images
to the browser is misbehaving. What further infuriates me
is I know I got this to work before so I know I'm probably
missing something fairly obvious. Here is the offending
sniglet of code:
use strict; use CGI qw/ :all /; use Image::Info; use GD; | | much handwaving for parts that already work fine. | my $imgStream; if ( $type eq 'PNG' ) { $imgStream = GD::Image->newFromPng($image); } else { $imgStream = GD::Image->newFromJpeg($image); } exec $0 if not $imgStream; print header(-type=>$mime); my $png_data = $imgStream->png; binmode STDOUT; print $png_data; close STDOUT; exit(0);
What I'm seeing at the browser is that oh-so-useful Error 500 error. Checking the server error logs I see:
If I play around with the script a little run it as a command line script the right data is being generated for the image and can be loaded by Eye Of Gnome just fine. It just doesn't seem to work as a CGI.[Tue Aug 7 14:21:59 2007] [error] [client 68.37.143.39] Premature end + of script headers: /home/bcdcweb/public_html/cgi-bin/sendRandomImage +.pl
What am I missing here???
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |