If this is the full code, you do not assign a value to $sigla is the first
thing that I see.
 

  _____  

From: Cristi Ocolisan [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 22, 2005 5:20 AM
To: beginners@perl.org
Subject: upload question



Hi all,

 

Does anybody know why this code does NOT copying the file into the specified
directory?

After the script is executed, my file is listed into the directory, but
empty.

 

Strange?

 

my $upload_dir = "../../witp/sigle_firme";

my $max_size = 1024_000;

 

my $file_name;

 

    if ( length($sigla) > 0  ) {

        ( $file_name = $sigla ) =~ s/.*\\//;

        my $upload_path = "$upload_dir/$file_name";      

    

        open (OUT, ">$upload_path") or die "Error opening $upload_path: $!";

        binmode OUT;    

    

        my $buffer = '';

        my $size = 0;

 

        while (my $chars_read = read($sigla, $buffer, 4096)) {

            print OUT $buffer;

            $size += $chars_read;

    

            if ( $size > $max_size ) {                

                last;

            }

            

        }

        close OUT;

 

        if ( -z $upload_path or $size > $max_size ) {

            unlink $upload_path;

        }

 

    }

 

 

It is strange because I wrote this code earlier and it was working
perfectly.

Please make me understand why it does not want to work anymore  :-).

 

Thanks.

 

CO

 

 

 

 

Reply via email to