Perl is your friend. You can write a Perl script that returns image data instead of text data.
Now if you use an IMG tag and put the .cgi script as the URL, if you refresh this page and it should show a random picture.Code:#!/usr/bin/perl -T use strict; use warnings; use CGI; my $filename = int(rand(2)); ($filename == 1) ? ($filename = 'tux2.png') : ($filename = 'tux.png'); if(open FILE, "<", $filename) { print CGI::header('image/png'); binmode FILE; print while(<FILE>); close FILE; } else { print CGI::header(); print "Error: $!"; }
<img src="http://chwombat.net/cgi-bin/picture.cgi">
gives
<img src="http://chwombat.net/cgi-bin/picture.cgi">



Reply With Quote