From ee791ee09b0036afba286ca8729f3051db3dc8da Mon Sep 17 00:00:00 2001 From: qorg11 Date: Sun, 26 Apr 2020 00:58:10 +0200 Subject: [PATCH] Added variable --- http/upload.cgi | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/http/upload.cgi b/http/upload.cgi index c876fb6..65bfa89 100755 --- a/http/upload.cgi +++ b/http/upload.cgi @@ -15,23 +15,30 @@ # along with lainsafe. If not, see . use CGI; - +use CGI::Carp qw(fatalsToBrowser); my $q = CGI->new; -print $q->header(); + +my $filename = $q->param('file'); # TODO: fix 502 my $upload_dir = "files/"; -my $filename = $q->param("file"); +print $q->header(); +$size = $ENV{CONTENT_LENGTH}; +$MAX_SIZE = 1024*1024*10; # Change for your size +$MAX_SIZE_MB = $MAX_SIZE / 1024 / 1024; # Don't change this if($filename eq "") { print("What are you looking for?"); exit; } +if($size > $MAX_SIZE) +{ + print("Max size for a file is $MAX_SIZE_MB MBs"); + exit; +} my $extension = $filename; $extension =~ s/.*\.//; - - my @chars = ("A".."Z", "a".."z"); my $string; $string .= $chars[rand @chars] for 1..8;