Corrupt downloads

I have a piece of PHP code that serves digital downloads securely (usually .zip files) using a download code. I moved this from another server, made all necessary modifications and so forth.

It seems to be working fine for most people. But some are experiencing corrupted downloads. I cannot recreate this on any of the two Macs or PCs at home, but I have had enough customers complain that I know this is not imaginary.

Some are complaining of “Safari Domain 0,” most are citing a corrupt zip when they download the file.

I have recreated the php.ini from the original server. Obviously it’s not identical, but all configurable settings are the same.

I’ve checked headers using a Firefox extension and am not getting any irregularities.

I’m hoping someone out there knows exactly what is going on and can help me. Thanks everyone.

Tried something like this?

<?php header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename=""'); readfile(''); ?>
Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

Thanks for replying sXi.

Here’s my header code. I’ve checked the headers, as well as opened the file and it seems like everything is fine. Again, this is happening only on certain peoples’ computers - I can’t replicate the problem on any of mine. Everything seems fine. And it’s not just every 5 downloads - it is definitely certain people who just absolutely cannot download it no matter what they do or what browser they are using.

header(“Pragma: public”);
header(“Expires: Thu, 19 Nov 1981 08:52:00 GMT”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: no-store, no-cache, must-revalidate”);
header(“Cache-Control: private”);
header(“Content-Transfer-Encoding: binary”);
header(“Content-type: application/octet-stream”);
//header(“Content-Type: audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3”);
// This line causes the browser’s “save as” dialog
header( ‘Content-Disposition: attachment; filename="’.$f[‘basename’].’"’ );
// Length required for Internet Explorer
header("Content-Length: ".@urldecode(@filesize($theFile)));

I should add that it seems that downloads cut out on people after a certain time, and that Mac users get a “Safari Domain Error 0.” It’s very annoying and strange. And it can’t be the code because it was running just dandy on our old server.

Ok. I figured out the problem, just not the solution.

The problem is that the download times out at roughly 5m30s to 5m45s every time, no matter the size. I was not seeing this because I have a 15mbps connection - but once I generated a large enough file I experienced the same errors my customers have been seeing.

I’m guessing this is something in php.ini - I’m using the custom wrapper - but everything seems kosher. Any ideas out there? Are there apache settings that would cause this problem?

I should also say direct http links not passed through php download just dandy.

If I was going to take a wild guess, it might be max_execution_time and/or max_input_time that needs to be increased.


Could be the ever-omnipresent mod_security.

You can get rid of that on a per dir basis via .htaccess :slight_smile:

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost