PDA

View Full Version : File Uploadf


naqvia
02-12-2007, 06:38 PM
Hi,

I can't seem to get the file uploading correct. I see the file name in the local server machine, but with no content! The permissions were all changed and I can't see the content at all (i need to parse it eventually). Please help. Here is my code,

my $filename = $q->param('file');
print $FORM{'file'};

## for standard input stream
if ( $FORM{'start'} =~/\d+/ ){
$start_position = $FORM{'start'};
$end_position = $FORM{'end'};
$start_position = $start_position;
$end_position = $end_position;
$chr_num = $FORM{'chromosome'};
related_genes($start_position,$end_position, $chr_num);
}

## for multiple sets of positions from a file
else {
# open (POS, $ARGV[0]) || die("Cannot Open File");
$chr_num = $FORM{'chromosome'};
my $i = 0; ## general counter to track the number of sets in file
open (UPLOADFILE, ">$filename");
while ( <$filename> )
{
print UPLOADFILE $_;
}
close UPLOADFILE;

FishMonger
02-12-2007, 06:59 PM
Try using the CGI's upload function and use separate vars for the filehandles.

my $localfile = $FORM{'file'};
my $filename = $q->upload('file');

open (UPLOADFILE, ">", $localfile) || die $!;
while ( <$filename> )
{
print UPLOADFILE $_;
}
close UPLOADFILE;

naqvia
02-12-2007, 07:14 PM
I get same thing... a blank file with no content in local server machine...