Incorrect file download problem.

S

Sphinx

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
 
G

Gunnar Hjalmarsson

Sphinx said:
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;
 
B

Brian McCauley

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\\
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top