Okay I copied Dr Unne's code, set up a webserver here on my computer, and put the cgi file in there. I then put two images in the directory.
It doesn't work. I get a red 'x' when I run the html file that has the image tag.
Code:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
my $filename = int(rand(2));
($filename == 1) ? ($filename = 'F_H.jpg') : ($filename = 'takebacktheweb_large.jpg');
if(open FILE, "<", $filename) {
print CGI::header('image/png');
binmode FILE;
print while(<FILE>);
close FILE;
} else {
print CGI::header();
print "Error: $!";
}
Code:
[html]
[body]
[img src="http://192.168.2.103/pics.cgi" /]
[/body]
[/html]