CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
cgi input file size

 



hostage
Novice

Mar 3, 2012, 2:45 AM

Post #1 of 2 (2471 views)
cgi input file size Can't Post

i'm writing a code to upload my files to a webserver so i have cgi code and a file input type in html how can i get the entry file size ?

i searched about it and i got that it's possible to use the $ENV{CONTENT_LENGTH} variable to get the file size but it seems that it first get the whole content and then return the size but my goal is to get the file size before fetching it.


thanks
hostage


winfinit
User

Jul 13, 2012, 1:01 PM

Post #2 of 2 (1481 views)
Re: [hostage] cgi input file size [In reply to] Can't Post

you can try to use HEAD request, and extract content length:


use strict;
use warnings;

use LWP::UserAgent;
use Data::Dumper;

my $browser = LWP::UserAgent->new;
my $response = $browser->head('http://mirrors.kernel.org/gnu/git/gnuit-4.9.3.tar.gz');
$response->content_length;

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives