PerlIsGood
Programmer
I've read through and used most of the code from goBoating's faq219-406. I've also read through CGI.pm on file uploading - still can't get this bloody thing to work. It will create the file on the server, but with 0 size - seems to me read isn't doing what it's supposed to. Anyway, if anyone can point out the flaw in my code I'd be greatly appreciative.
I've tried every file-type I could get my hands on, all with the same results. All error trapping works prior to hitting this sub, and print de-bugging %query checks out (all data in proper format/expected format) ... I'm confused... Notorious P.I.G.
Code:
@file = split /\\/, $query{'fileID'};
$new_dir = "../_files/$query{'game'}/$query{'section'}/";
$new_file = $file[$#file];
sub process_success {
my ( $bytes_read, $sum_bytes, $buffer );
open OPF, "> $new_dir/$new_file" or die "Could not create $new_file on the remote server: $!";
print $q->header;
print "Uploading '$query{'fileID'}' to the server...!";
while ( $bytes_read = read ($query{'fileID'}, $buffer, 1024) ) {
print OPF $buffer;
$sum_bytes += $bytes_read;
if ( $sum_bytes > 27000 ) {
close OPF;
unlink "$new_dir/$new_file";
$err_count++;
last;
}
}
close OPF;
print $q->end_html;
}
I've tried every file-type I could get my hands on, all with the same results. All error trapping works prior to hitting this sub, and print de-bugging %query checks out (all data in proper format/expected format) ... I'm confused... Notorious P.I.G.