[Buffalo-pm] CGI.pm uploadinfo filesize

joshj@linuxmail.org joshj at linuxmail.org
Wed Mar 1 15:20:07 PST 2006


How exactly do you get the filesize of an uploaded file? I'd like to use
it so I could display progress to the user. Everything seems to say to
use uploadInfo from CGI.pm or upload_info from CGI::Simple. The only one
that even returns anything useful is CGI.pm. It gives me content-type,
content-disposition, name, and filename. But no file size. So I'm
thinking that maybe there is something more I should specify in the html
to tell the client that I want that information. Here is my html form:

<form method="post" action="oldup.cgi" enctype="multipart/form-data">
<input type="file" name="upfile" /><input type="submit" /></form>

and the cgi:

use strict;
use CGI qw(:standard uploadInfo);
use Data::Dumper;

my $q = new CGI;
my $fname = param('upfile');
my $fsize = $q->uploadInfo($fname);
print <<"html";
Content-type: text/html

<h1>UpLoad File</h1>

file: $fname<br />

<b>Done $fsize</b>
html
print Dumper($fsize);

------------------------------
Any ideas how to get this information?

-Josh J


More information about the Buffalo-pm mailing list