L
LMario
I am using the next Perl Script to download a .exe file:
The file can be download complete (well almost: Opera send a error
when the download finishes) by the brownser but it arrives corrupted.
I mean it can´t be executed. It is windows application and when a
execute the downloaded file appears a DOS window, which send the error
message "The file can't be executed in DOS mode".
I don't know if I am not generating the apropiate headeres with the
Perl Script or if I need configurate something with Apache
-Text files can be download well with the script.
#!E:\Perl5p8p8\bin\perl.exe -wT
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
my $file_location;
my $filename;
my $filesize;
my @fileholder;
$file_location = "D:\\MiSitioWEB\\SPE\\cgi-bin";
$filename = 'Setup.exe';
$filesize = -s "$file_location\\$filename";
open(DLFILE, "<$file_location\\$filename") ||
Error('abrir','archivo');
@fileholder = <DLFILE>;
close (DLFILE) || Error ('close','file');
open(LOG,">>D:\\MiSitioWEB\\SPE\\cgi-bin\\ContDesSPE.log")||
Error('abrir','archivo');
print LOG "$filename\n";
close(LOG);
print "Content-length: $filesize\n";
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$filename\n\n";
print @fileholder;
exit;
sub Error
{
print "Content-type: text/html\n\n";
print "El servidor no puede $_[0] el $_[1]: $! \n";
exit;
}
The file can be download complete (well almost: Opera send a error
when the download finishes) by the brownser but it arrives corrupted.
I mean it can´t be executed. It is windows application and when a
execute the downloaded file appears a DOS window, which send the error
message "The file can't be executed in DOS mode".
I don't know if I am not generating the apropiate headeres with the
Perl Script or if I need configurate something with Apache
-Text files can be download well with the script.
#!E:\Perl5p8p8\bin\perl.exe -wT
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
my $file_location;
my $filename;
my $filesize;
my @fileholder;
$file_location = "D:\\MiSitioWEB\\SPE\\cgi-bin";
$filename = 'Setup.exe';
$filesize = -s "$file_location\\$filename";
open(DLFILE, "<$file_location\\$filename") ||
Error('abrir','archivo');
@fileholder = <DLFILE>;
close (DLFILE) || Error ('close','file');
open(LOG,">>D:\\MiSitioWEB\\SPE\\cgi-bin\\ContDesSPE.log")||
Error('abrir','archivo');
print LOG "$filename\n";
close(LOG);
print "Content-length: $filesize\n";
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$filename\n\n";
print @fileholder;
exit;
sub Error
{
print "Content-type: text/html\n\n";
print "El servidor no puede $_[0] el $_[1]: $! \n";
exit;
}