use strict; use lib '/wasd_root/src/perl/cgipm'; require CGI; use CGI qw(:standard); my $query = new CGI; print $query->header(); # when being strict we need to cast a tainted variable to a string my $tfilename = $query->param('upload'); my $filename = $tfilename; my $tmpFileName = $query->tmpFileName($filename); my $mimeType; $mimeType = $query->uploadInfo($filename)->{'Content-Type'}; print "Using GGI.pm to demonstrate file upload!

FileName: ", $filename, "

tmpFileName: ", $tmpFileName, "

MIME type: ", $mimeType, "

";

if ($mimeType eq 'text/plain')
{
   my $length = 0;
   my $fh = $query->upload('upload');
   while (my $record = <$fh>) {
      print escapeHTML($record);
      $length += length($record);
   }
   print
"

Document length: ", $length, " bytes"; } else { print "File content cannot be displayed unless plain text! "; } if (defined $main::perlRTEcount) { print "

Engine usage count: ", $main::perlRTEcount, "
Cached script usage count: ", $main::perlRTEcache; }