Downloading a .exe file with Apache and Perl

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top