#!/usr/bin/perl use POSIX; my $path = "/path/to/images"; my $imagereq = param('iwant'); #If you don't give an image, it assumes you #want image 0, the defaut image. unless($imagereq) { $imagereq = 0; } #If the image you requested exists (all are JPEG), then #we set our path to reflect this if(-e "$path/$imagereq".".jpg") { $path = "$path/$imagereq".".jpg"; } #Otherwise, we give them an special image else { $path = "$path"."404.jpg"; } #Open the image and 'print' it, which the browser #is quite happy to accept and display as an image open IMAGE, "$path" or die "ACK! $!"; print "Content-type: image/jpeg\n\n"; binmode STDOUT; while() { print STDOUT $_; }