[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-users
Subject: Re: can someone help me with my code?
From: Carl Jolley <cjolley () iac ! net>
Date: 2000-09-29 4:55:18
[Download RAW message or body]
On Tue, 26 Sep 2000, Fabio Quintao wrote:
> Hi everyone!!!
>
> i've been trying to check the size of 4 gif's files that people
> upload from my web site to a folder in my web server.i made the code
> below that supposed to check the size and then if it has more than 15K
> will show a error message. if it has less than 15K it will be include in
> my folder.i'm not preety sure if i've been doing the correct thing.i
> just know that when the files has less than 15K just one of than has
> been included with 0K.i'm probably overlooking somethimg.can someone
> help me!!!!
>
>
> &ver_pic;
>
> sub ver_pic {
>
> &default;
>
> for ($i=0;$i<=3;$i++) {
>
> open TEMPARQ, ">/xitami/cgi-bin/foto/$filed[$i]";
>
> binmode TEMPARQ;
>
> $buffer = '';
>
> while ($line = read ($filed[$i], $buffer, 4096)) {
>
> $size += $line;
>
> }
>
> close TEMPARQ;
>
>
> if ($size > 15000) {
> print "the file $pic[$i] is to much big\n";
> exit;
>
> }
>
> else {
>
> &include_pic;
> exit;
> }
>
> }
>
> }
>
>
> sub default {
>
> my $cgi = new CGI;
> $id=31;
> for ($p=1;$p<=4;$p++){
>
> $file1 = $cgi->upload("pict".$p);
> push(@filed,$file1);
>
> }
>
> $tmpdir = "/xitami/cgi-bin/foto/$id";
>
> ($filed2,$filed3,$filed4,$filed5) = @filed;
>
> ($pic1 = $filed2) =~ s/^.*?([^\\\/]+)$/$1/;
> ($pic2 = $filed3) =~ s/^.*?([^\\\/]+)$/$1/;
> ($pic3 = $filed4) =~ s/^.*?([^\\\/]+)$/$1/;
> ($pic4 = $filed5) =~ s/^.*?([^\\\/]+)$/$1/;
> push(@pic, $pic1,$pic2,$pic3,$pic4);
>
> }
>
> sub include_pic {
>
> &default;
>
> for ($i=0;$i<=3;$i++) {
>
> my $line;
>
> mkdir $id,"/xitami/cgi-bin/foto";
>
> closedir $id;
>
> $tmppath = "$tmpdir/$pic[$i]";
>
> $size = 0;
>
> open OUT, ">$tmppath";
>
> binmode OUT;
>
> $buffer = '';
>
> while ($line = read ($filed[$i], $buffer, 4096)){
>
> print OUT $buffer;
> $size += $line;
>
> }
>
> close OUT;
> }
>
> print <<EOD;
> <HTML>
> <BODY>
> <p>Files uploaded sucessfully
> </BODY>
> </HTML>
> EOD
>
> exit 0;
>
> }
>
Instead of reading the file to figure out its size why don't you
just use the '-s' file test function?
**** cjolley@iac.net <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic