Click here to get back home

downloading a big .exe fails

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
downloading a big .exe fails dino d. 07-10-2008
Get Chitika Premium
Posted by dino d. on July 10, 2008, 3:00 pm
Please log in for more thread options

Hi -

I have a restricted download I want to set up. It's about 19 megs.
It downloads fine, but it mysteriously adds 2 extra bytes to the
file. If I grab the file directly via ftp, it's fine, so I know the
file is good. I don't want to put the download in a public place
because I need to track who is downloading when. Here's the code:

function StartDownload()
{
$file='/products/demo/demo_installer.exe';
$filename='demo-installer.exe';

$fp = fopen($file, "rb");

header('Content-type: Application/Octet-Stream');
header('Content-Disposition: attachment; filename="demo-
installer.exe"');
header('Content-Encoding: none');

//readfile($file); //have tried this too,
fpassthru($fp);
fclose($fp);
}

Any ideas why this doesn't work and how to fix it?

I read somewhere else that http compression may be the culprit, but I
don't know if it's possible to turn off compression in the code
itself.

Thanks for any help,
Dino

Posted by AnrDaemon on July 10, 2008, 8:33 pm
Please log in for more thread options
Greetings, dino d..
In reply to Your message dated Thursday, July 10, 2008, 23:00:42,

> I have a restricted download I want to set up. It's about 19 megs.
> It downloads fine, but it mysteriously adds 2 extra bytes to the
> file. If I grab the file directly via ftp, it's fine, so I know the
> file is good. I don't want to put the download in a public place
> because I need to track who is downloading when. Here's the code:

> function StartDownload()
> {
> $file='/products/demo/demo_installer.exe';
> $filename='demo-installer.exe';

> $fp = fopen($file, "rb");

> header('Content-type: Application/Octet-Stream');
> header('Content-Disposition: attachment; filename="demo-
> installer.exe"');
> header('Content-Encoding: none');

> //readfile($file); //have tried this too,
> fpassthru($fp);
> fclose($fp);
> }

> Any ideas why this doesn't work and how to fix it?

> I read somewhere else that http compression may be the culprit, but I
> don't know if it's possible to turn off compression in the code
> itself.

I'm sure it is not your code, but the file where you have it placed.
Check it for any additional line breaks. Or better, remove anything before
"<?php" or after "?>", even linefeeds.
And I think that "header('Content-Encoding: none');" is worthless.


--


Similar ThreadsPosted
session_start() intermittently fails on the same page, then works, then works, then fails.. December 8, 2006, 11:40 am
Downloading a File October 29, 2004, 11:12 am
PHP-FTP Downloading Files October 31, 2006, 11:04 am
php files downloading February 16, 2007, 5:32 am
downloading pear packages September 6, 2004, 10:20 pm
Downloading and parsing web-stuff April 22, 2005, 2:51 am
Downloading without exact link April 30, 2005, 7:09 pm
Having problem while downloading some files. January 11, 2006, 6:26 pm
downloading blobs from mysql February 6, 2006, 7:30 am
errors after downloading a .csv file from php May 28, 2006, 11:22 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap