# Get the current time from the server
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$year += 1900;
$mon += 1;
#create you timestamp format to append
my $datetime = sprintf "%04d%02d%02d%02d%02d%02d", $year, $mon, $mday, $hour, $min, $sec;
#set the file name equal to the timestamp and file name given by the HTML form
my $file = $datetime . '-' . param("file_upload");
#initialize some variables
my ($total_size, $size, $data);
my $outputdir = '/home/user/file/dir';
#open the file you want to save the streaming data to
open(SAVE, ">$outputdir/$filename") or die "Can't open file: $!";
#set the filehandle to binary mode so you can accept all files
binmode SAVE;
#While you get data from the Form
while($size = read(param("file_upload"), $data, 1024))
{
#print the data chunk to the file handle you created on your server
print SAVE $data;
#add in the size you just wrote (used if you want to limit file sizes)
$total_size += $size;
}
#finished getting the file, so close the handle
close(SAVE);