my ($bytesread, $buffer); my $numbytes = 1024; my $filename2 = $query->param('filename'); open (OUTFILE, ">", "$upload_dir/$filename") or die "Couldn't open $upload_dir for writing: $!"; while ($bytesread = read($filename2, $buffer, $numbytes)) { print OUTFILE $buffer; } close OUTFILE;