Hi all,

 

First, because I’m new to this list, I want to salute you all.

 

Second, please help me understand where my error is …

 

Does anybody know why this code does NOT copy 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  J.

 

Thanks.

 

CO

 

-- 
This message was scanned for spam and viruses by BitDefender.
For more information please visit http://linux.bitdefender.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to