$filename = $sourcepath = $query->upload($file); $filename =~ /([\w. -]+)$/i; $filename = $1; $filename =~ s/ /_/g; my $size = $ENV{CONTENT_LENGTH}; if ($size > $max) { return ($filename,"File is too large to upload.",$size); } open(OUTPUT, ">$path/$filename") or return ($filename, "Cannot open '$filename'. Contact Webmaster"); ; binmode($filename); binmode(OUTPUT); while( read($sourcepath, $buffer, 64*2**10) ) { print OUTPUT $buffer; } close(OUTPUT);