Hi guys,
I am handling some upload functions in perl. And I got a problem that I really don't know how to figure it out.
Here is that. I have two files, basically they have the same code in the upload part. But one is working fine, one is not working. I got this error:
binmode() on closed filehandle UPLOADFILE at /spare/WWW/cgi-bin/uploadLindegren Current.pl line 62, <$fh> line 1.
readline() on unopened filehandle at /spare/WWW/cgi-bin/uploadLindegren Current.pl line 63.
I compare the upload parts between these two files, I cannot tell the difference. Could you guys be so kind to give me a hand.
Appreciate that!!!
Here is the code:
I am handling some upload functions in perl. And I got a problem that I really don't know how to figure it out.
Here is that. I have two files, basically they have the same code in the upload part. But one is working fine, one is not working. I got this error:
binmode() on closed filehandle UPLOADFILE at /spare/WWW/cgi-bin/uploadLindegren Current.pl line 62, <$fh> line 1.
readline() on unopened filehandle at /spare/WWW/cgi-bin/uploadLindegren Current.pl line 63.
I compare the upload parts between these two files, I cannot tell the difference. Could you guys be so kind to give me a hand.
Appreciate that!!!
Here is the code:
Code:
......
use Tie::File;
$upload_dir = "../uploadTest";
$query = new CGI;
$data_file="lindegrenChoice.cgi";
open(DAT, $data_file) || die("Could not open file!");
@raw_data=<DAT>;
tie @line, 'Tie::File', $data_file or die("Can not open file!");
.......
for($i=1; $i<=$count; $i++){
if($current eq $sname[$i]){
$filename =~ s/.*[\/\\](.*)/$1/;
@exten = split('\.', $filename);
$filetype = ".";
$filetype .= $exten[1];
$newfilename = "current_lindegren";
$newfilename .= $filetype;
$upload_filehandle = $filename;
$line[$i-1]="$i|$sname[$i]|1|1|$filetype";
open UPLOADFILE, ">$upload_dir/$newfilename";
binmode UPLOADFILE;
while ( <$upload_filehandle> ) {
print UPLOADFILE;
}
close UPLOADFILE;
}
else {
if($scurrent[$i]==0){
$line[$i-1]="$i|$sname[$i]|$sexist[$i]|0|$stype[$i]";
## print "line $i-1 is $line[$i-1] <br>";
}
else{
$line[$i-1]="$i|$sname[$i]|0|0|$stype[$i]";
}
}
}
close(DAT);
Comment