#!/usr/bin/perl use CGI; $q = new CGI; print $q->header, $q->start_html(-title=>"Upload Results",-bgcolor=>"white"); print $q->h2("Upload Results"); $file = $q->param("upfile"); if (!$file) { print "Nothing uploaded?
\n";
} else {
print "Filename: $file
\n";
$ctype = $q->uploadInfo($file)->{'Content-Type'};
print "MIME Type: $ctype
\n";
#where is ">$file" going to be written to? and how to set to different directory?
open(OUT,">$file") or dienice("Can't open outfile for writing: $!");
$flen = 0;
while (read($file,$i,1024)) {
print OUT $i;
$flen = $flen + 1024;
if ($flen > 5120000) {
close(OUT);
dienice("Error - file is too large. Save aborted.
"); } } close(OUT); print "Length: ",$flen/1024,"Kb
\n"; print "File saved!
\n"; # display the image. this only works because we have a symlink from # tmp.gif/jpeg in the current directory, to /tmp/outfile. if ($ctype eq "image/gif") { print "Here's what you sent:
\n"; print "
\n"; } elsif ($ctype eq "image/jpeg") { print "Here's what you sent:
\n"; print "
\n"; } } $q->end_html; sub dienice { my($msg) = @_; print "
\n"; exit; }