How can I get the file size in Perl before processing the download request?

I want to get the file size. I'm doing it:

my $filename=$query->param("upload_file");
my $filesize = (-s $filename);
print "Size: $filesize ";`

But it does not work. Please note that I did not upload the file. I want to check its size before downloading it. Therefore, to limit it to 1 MB.

+3
source share
8 answers

- . Content-Length, , . , . , Content-Length , , . , .

, , CGI, $ENV{CONTENT_LENGTH}.

+5

, , - ( perldoc CGI):

$CGI::POST_MAX

, POST, . CGI.pm POST, , . POST POST, , . , 1 .

+2

tmp , .

$.

my $upload_filehandle = $query->upload($field);
my $tmpfilename = $query->tmpFileName($upload_filehandle);
my $file_size = (-s $tmpfilename);
+2

Perl.

, , Perl.

, , , , .

, .

+1

, , -, . , - , Flash, Flash, , ( ) .

YUI Uploader. : JavaScript/Flash ?

, , , , .

+1

; , $filesize = (-s $filename); , - , Ajax, . , . , , . .

+1

, , , . , .

0

Source: https://habr.com/ru/post/1742767/


All Articles