Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Incorrect file download problem.

Reply
Thread Tools

Incorrect file download problem.

 
 
Sphinx
Guest
Posts: n/a
 
      06-28-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      06-28-2004
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
 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      07-02-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (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\\
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forcing Download of File Appends HTML from Download Page to Downloaded File? Brett Kelly ASP .Net 1 06-16-2006 04:05 AM
problem with code download file - two window file download Sam -- ASP .Net 2 03-17-2005 04:20 PM
Re: How can I display a download link in my (C#) ASP.NET web form to download a file stored in my sql db? Steve C. Orr [MVP, MCSD] ASP .Net 0 03-07-2005 07:14 PM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM



Advertisments