[Buffalo-pm] CGI.pm uploadinfo filesize

DANIEL MAGNUSZEWSKI dmagnuszewski at mandtbank.com
Fri Mar 3 07:09:44 PST 2006


This page may help a little - check out the bottom of the last example
(http://perlmeme.org/tutorials/cgi_upload.html):


        while ($bytesread = read($filename, $buffer, $num_bytes)) {
            $totalbytes += $bytesread;
            print OUTFILE $buffer;
        }

I can't find anything on it right now, but I was told that there is a
"FILE" (or something similar) entry in the %ENV (environment variable)
hash. It should contain a whole bunch of information on the file (name,
size, etc). If this is the case, then you can simply grab the filesize
and use the above while loop and compare the bytes read with whatever
the total number of bytes is. 

I'm not a "web guy" so I'm not too familar with using %ENV beyond its
basic uses. Does anyone else know if the filesize is in %ENV?

-Dan


>>> <joshj at linuxmail.org> 03/01/06 6:20 PM >>>
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
_______________________________________________
Buffalo-pm mailing list
Buffalo-pm at pm.org 
http://mail.pm.org/mailman/listinfo/buffalo-pm 




More information about the Buffalo-pm mailing list