Incorrect file download problem.

Discussion in 'Perl Misc' started by Sphinx, Jun 28, 2004.

  1. Sphinx

    Sphinx Guest

    Hi,

    On my website, I am trying to use following perl script to download an
    ..exe file from server. This script downloads a smaller file then the
    original one, (leaving nearly 100 bytes). I tried to compare the
    contents (binary) of both files and they are same.

    I am not sure why the size changed but there is no content change. The
    exe file is a program installable and I am unable to install it after
    download.

    Even I tried to download a zip file with mime application/zip, that is
    also invalid with 57 bytes missing and winzip doesn't read that. Text
    file download works file.

    I think I am using correct mime type; anyone has any idea, what could
    be the problem?

    Here is the script.

    my $fileName="myfile.exe";
    open(OUTFILE, $fileName) || die "Unable to open file..\n";
    print "Content-type: application/octet-stream \n";
    print "Content-disposition: filename=\"$fileName\"\n";
    print "Content-Description: my exe file \n\n";

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

    Thanks
    -Kamran
     
    Sphinx, Jun 28, 2004
    #1
    1. Advertising

  2. Sphinx wrote:
    > On my website, I am trying to use following perl script to download
    > an .exe file from server. This script downloads a smaller file
    > then the original one, (leaving nearly 100 bytes). I tried to
    > compare the contents (binary) of both files and they are same.
    >
    > I am not sure why the size changed but there is no content change.
    > The exe file is a program installable and I am unable to install it
    > after download.
    >
    > Even I tried to download a zip file with mime application/zip, that
    > is also invalid with 57 bytes missing and winzip doesn't read that.
    > Text file download works file.
    >
    > I think I am using correct mime type; anyone has any idea, what
    > could be the problem?
    >
    > Here is the script.
    >
    > my $fileName="myfile.exe";
    > open(OUTFILE, $fileName) || die "Unable to open file..\n";


    binmode OUTFILE;
    binmode STDOUT;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Jun 28, 2004
    #2
    1. Advertising

  3. (Sphinx) writes:

    > On my website, I am trying to use following perl script to download an
    > .exe file from server. This script downloads a smaller file then the
    > original one, (leaving nearly 100 bytes). I tried to compare the
    > contents (binary) of both files and they are same.


    It is impossible for two files of different sizes to have identical
    content. What did you really mean to say?

    > I think I am using correct mime type; anyone has any idea, what could
    > be the problem?


    You forgot to open the file in binary mode. (perldoc -f binmode).

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
     
    Brian McCauley, Jul 2, 2004
    #3
    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. Ryan Taylor
    Replies:
    2
    Views:
    1,024
    Ryan Taylor
    Nov 10, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,666
    Steve C. Orr [MVP, MCSD]
    Mar 7, 2005
  3. Sam --
    Replies:
    2
    Views:
    665
    Sam --
    Mar 17, 2005
  4. Brett  Kelly
    Replies:
    1
    Views:
    721
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
  5. Chris Dwan
    Replies:
    4
    Views:
    170
    Nobuyoshi Nakada
    Jul 23, 2007
Loading...

Share This Page