Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
sub Upload{ my $self = shift; my $q = $self->query(); my $emailbody; my $bytes_retreived = 0; my $bufsize = 1024; my $buffer = ''; my $fh = $q->upload('upfile'); my $filename = uc( $q->param('upfile') ); return '' if ! $filename; my $tmp = File::Temp->new( DIR => $self->cfg('UploadDIR'), SUFFIX => '.zip', UNLINK => 0, ); warn "temp file - $tmp"; binmode $fh; while (read ($fh, $buffer, $bufsize)) { print $tmp $buffer; $bytes_retreived += $bufsize; warn "bytes recieved: $bytes_retreived"; # I expect to see thi +s in real time when tailing the error_log } close $fh; #close $tmp; my $file = $self->session->param('UPLOADPATH') . "/" . $filename; warn "file -- $file"; move($tmp, $file) or die "file move failed $!"; # some more code follows which isn't relevant to the problem. }
|
|---|