# add this to the script if ($q->('request') eq 'download') { &DownloadFile( $filepath, $filename ); exit; } sub DownloadFile { my ($filepath,$filename) = @_; my $filesize = -s "$filepath/$filename"; print "Content-disposition: attachment; filename=$filename\n"; print "Content-Length: $filesize\n"; print "Content-Type: application/octet-stream\n\n"; my $buffer; open FILE, "$filepath/$filename" or die "Oops $!"; binmode FILE; binmode STDOUT; print $buffer while (read(FILE, $buffer, 4096)); close FILE; }