use CGI qw/:standard/;
my $UploadDir = $TEMP_DIR;
$CGI::POST_MAX=1024 * $MAX_SIZE_UPLOAD;
my ($filename) = param('attachment') || "undefined";
print header, start_html;
print ("Filename: $filename
");
my $serverFile = $UploadDir . "/" .
(split(/[\\\/]/, param('attachment')))[-1];
if (-e $serverFile) {print ("File is already existing
");}
else
{
print ("Writing to file $serverFile
");
my $buffer;
open (FILE,">$serverFile");
binmode(FILE); # Windows OS hack
binmode $filename; # Windows OS hack
while (my $bytesread=read($filename,$buffer,1024)) {print FILE $buffer;}
close (FILE);
}
chmod (0744, "$serverFile");
print end_html;