my $outputFile;
if( $_file_name !~ /^(\s*)$/ ) {
####
use constant BUFFER_SIZE => 16_384; # Amount of upload file to read at
one time
use constant MAX_FILE_SIZE => 3_145_728; # This is the filesize upload limit
##
##
$CGI::DISABLE_UPLOADS = 0; # Temporarily reenable uploads
$CGI::POST_MAX = MAX_FILE_SIZE;
##
##
# Path and Filename
my $file_name = $_file_name;
##
##
my $file_type = $query->uploadInfo($file_name)->{'Content-Type'};
my $basename = basename($file_name);
##
##
if( $file_type =~ /octet-stream/ ) {
$errors{ 'file_type' } = ["","","Unrecognize your submitted resume file
format."];
goto Print;
}
##
##
$outputFile = $UPLOAD_RESUME_DIRECTORY . $basename ;
my $buffer = "";
open(OUTPUT,">>$outputFile");
##
##
my @stats;
# Need binmode or Win32 systems will convert end-of-line chars
binmode OUTPUT;
{
no strict 'refs';
READ_FILE: while ( read( $file_name, $buffer, BUFFER_SIZE ) ) {
print OUTPUT $buffer;
@stats = stat $outputFile;
last READ_FILE if ( $stats[7] > MAX_FILE_SIZE )
}
}
close(OUTPUT);
##
##
#check the file size
if ( $stats[7] > MAX_FILE_SIZE || %errors ) {
$errors{'file_size'} = ["","","Your submitted file's size is over 3MB."]
;
unlink $outputFile;