in reply to
uploading a image file
Okay, this is going to sound stupid, but if no one else comes up with a solution I would suggest that you mess with the code using alternative methods to achieve the same results. Personally I use CGI::Simple, but I've had even more problems with that module for some unknown reason than I've had with strait CGI;
For some reason on occasion I have severe problems with the "upload" routine of CGI. Instead I sometimes use the older method.
my $fh = $cgi->param('file');
open FILE, ">whatever";
print FILE while (<$fh>);
Reading the file in blocks as you have it is a better solution, but this is pretty tried and true for getting it to work initally.
CGI::Simple also provides:
my $st = $cgi->upload( $cgi->param('file'), ">whatever");