Downloading a .exe file with Apache and Perl

Discussion in 'Perl Misc' started by LMario, May 4, 2007.

  1. LMario

    LMario Guest

    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;
    }
     
    LMario, May 4, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    408
  2. Fabiano
    Replies:
    1
    Views:
    4,122
    Kevin Spencer
    Dec 11, 2003
  3. Tom Salzmann
    Replies:
    3
    Views:
    263
  4. The Poor
    Replies:
    2
    Views:
    237
    Gregory Toomey
    Sep 27, 2003
  5. Bartek Lakomiec
    Replies:
    4
    Views:
    242
    Eric Schwartz
    Apr 5, 2007
Loading...

Share This Page