File download with mod_perl

I am using following script in perl to download a file from the server to the local machine. The great thing about this code is, it populates a file save as dialog. The dialog is populated becuase of "Content-type:application/unknown\n Content-disposition:attachment;filename=$filetobedownloaded\n\n".


my ($in) = new CGI;
my ($filetobedownloaded)  = $in->param('filetobedownloaded');
my ($working_dir) = $in->param('wd');

print "Content-type:application/unknown\n Content-disposition:attachment;filename=$filetobedownloaded\n\n"
my $directory = "$config{'root_dir'}/$working_dir";

open (OUTFILE, "$directory/$filetobedownloaded");
binmode OUTFILE;
binmode STDOUT;

while (<OUTFILE>) { 
 $in->print($_); 
} 
close (OUTFILE); 


However, the same code is not working under mod_perl. The file content is the same as original file, but filename is populated as download.cgi instead of actual file name. I think mod_perl is putting its own headers, while sending the data.

Any help regarding this, will be greatly appreciated.

Thanks,
Pritesh.

Received on Thursday, 17 August 2000 06:00:37 UTC