Incorrect file download problem.

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

  1. Sphinx

    Sphinx Guest


    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

    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 $_;

    Sphinx, Jun 28, 2004
    1. Advertisements

  2. binmode OUTFILE;
    binmode STDOUT;
    Gunnar Hjalmarsson, Jun 28, 2004
    1. Advertisements

  3. It is impossible for two files of different sizes to have identical
    content. What did you really mean to say?
    You forgot to open the file in binary mode. (perldoc -f binmode).

    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
    Brian McCauley, Jul 2, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.