#!/usr/bin/perl # Read Picture # By Brian Prentice # February 1997 $params = ; $size = $ENV{'CONTENT_LENGTH'} - length($params); chop($params); @params = split /;/, $params; $path = "/var/www/html/$params[0]/$params[1]/$params[2]"; $filename = "<" . $path; $header = "<--Picture File-->\n"; open FILE, $filename; read (FILE, $data, length($header)); if ($data ne $header) { close FILE; $message = "Error: Incorrect File Type\n"; print "Content-type: text/plain\n"; print "Content-length: " . length($message) . "\n\n"; print $message; exit(1); } read (STDIN, $pos, $size); if ($pos != 0) { if ($pos >= (stat FILE)[7]) { $pos = length($header); } seek(FILE, $pos, 0); } read (FILE, $size, 6); $size =~ s/^ +//; read (FILE, $data, $size); $pos = sprintf("%8d", tell(FILE)); close FILE; $size += 8; print "Content-type: text/plain\n"; print "Content-length: $size\n\n"; print $pos; print $data; exit(0);