I worked it out in the end.
Its head slappingly simple
Thanks everyone
Heres the finished script:-
#!/usr/bin/perl -w
=comment
This is for customer proofs NOT cam/management proofs
Responds to a request for a customer proof image from the internet
+.
Reads the requested image from disk and serves it back to the brow
+ser.
Used to serve private images that are not on the apache tree in re
+sponse to a browser request to
fill an image tag eg
<img src=\"http://www.caralan.com/cgi-bin/customer_image_server.cg
+i?load_image=cust__stevecaralancom1129266425_00.gif\" border=\"0\" a
+lt=\"\">
=cut
use strict;
use CGI;
#use File::Copy;
#use Tie::File;
#use Fcntl qw( :DEFAULT :flock );
use steves_general_functions;
my $mycgi = new CGI;
my $imagedata = "";
my $load_image = $mycgi->param( "load_image" );
$load_image = &gen_wash_input($load_image, "filename");
my $proof_folder = "/caralan_com/system/proofing/customer_proofs/proof
+s_out/";
my $imagefile = $proof_folder . $load_image;
#Set mime type for returned binary dump
if( lc(&gen_get_extension_from_path($imagefile)) eq ".gif"){
print "Content-type: image/gif\n\n";
}
if( lc(&gen_get_extension_from_path($imagefile)) eq ".jpg"){
print "Content-type: image/jpeg\n\n";
}
if( lc(&gen_get_extension_from_path($imagefile)) eq ".tif"){
print "Content-type: image/tif\n\n";
}
#Slurp binary image data from diskfile
{
local( $/, *IMAGEFILE ) ;
open( IMAGEFILE, $imagefile );
$imagedata = <IMAGEFILE>;
close IMAGEFILE;
}
#Send binary dump to browser
print $imagedata;
|