develooper Front page | perl.beginners | Postings from February 2002

Re: file size

Thread Previous
From:
Jon Molin
Date:
February 22, 2002 06:34
Subject:
Re: file size
Message ID:
3C76566C.5ABFFCD9@resfeber.se
anthony wrote:
> 
> Hi,
> 
> I have an upload script, and i want to check the file size before it
> uploads.
> 
> Any suggestion is appreciated
> 
> Anthony
> 

here's some old code that does that, might be something built-in in
CGI.pm as well:


    my $tempFile = CGI::tmpFileName($img_filename);
    my @file_info = stat ($tempFile);
    

    if ($#file_info > 0 && $file_info[7] < $max_size && 
        $file_info[7] > 0)
    {
        copy($tempFile, $path.$filename);
    }
    else
    {
        error_msg ("Max size is $max_size");
    }
}


> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About