U
Us
Hello everybody,
I've a problem with a file download script written in Perl. When I call
it from Firefox it's OK, but when I call it from IE, it's not.
The IE download dialog is launched, but IE try to search info about the
file and fails to do-it. Thus, I get an error message saying "IE cannot
download download.cgi?test.rar from www..."
What's the problem with this script and IE ?
The code is this :
#!/usr/bin/perl -w
use CGI ':standard';
my $ID = param('ID');
my $files_location = "../httpdocs/repository";
my @fileholder;
if ($ID eq ''){
print "Content-type: text/html\n\n";
print "no file parameter";}
else{
open(DLFILE, "<$files_location/$ID") || Error('open', 'file');
binmode DLFILE;
@fileholder = <DLFILE>;
close (DLFILE) || Error ('close', 'file');
open (LOG, ">>download.log") || Error('open', 'file');
print LOG "$ID\n";
close (LOG);
binmode STDOUT;
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder}
sub Error{
print "Content-type: text/html\n\n";
print "server can't $_[0] the $_[1]: $! \n";
exit;}
It's called using url like (here a fictive one) :
http://www.mydomain.org/cgi-bin/download.cgi?ID=test.rar
knowing test.rar is present in the repository directory.
I've a problem with a file download script written in Perl. When I call
it from Firefox it's OK, but when I call it from IE, it's not.
The IE download dialog is launched, but IE try to search info about the
file and fails to do-it. Thus, I get an error message saying "IE cannot
download download.cgi?test.rar from www..."
What's the problem with this script and IE ?
The code is this :
#!/usr/bin/perl -w
use CGI ':standard';
my $ID = param('ID');
my $files_location = "../httpdocs/repository";
my @fileholder;
if ($ID eq ''){
print "Content-type: text/html\n\n";
print "no file parameter";}
else{
open(DLFILE, "<$files_location/$ID") || Error('open', 'file');
binmode DLFILE;
@fileholder = <DLFILE>;
close (DLFILE) || Error ('close', 'file');
open (LOG, ">>download.log") || Error('open', 'file');
print LOG "$ID\n";
close (LOG);
binmode STDOUT;
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder}
sub Error{
print "Content-type: text/html\n\n";
print "server can't $_[0] the $_[1]: $! \n";
exit;}
It's called using url like (here a fictive one) :
http://www.mydomain.org/cgi-bin/download.cgi?ID=test.rar
knowing test.rar is present in the repository directory.