HTTP headers!

Soldato
Joined
26 Dec 2003
Posts
16,522
Location
London
Can someone well versed in the intricacies of murky HTTP magic tell me why the heck this produces corrupt downloads for some people?

Code:
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename='.basename($filename));
header('Content-Length: '.filesize($filename));
readfile($filename);

$filename is and always will be a zip file, so I don't need to mess about with dynamically working out the mime-type. As far as I and Google know, application/zip is universally understood, so it can't be that. From examining the headers sent, the content-length is accurate, and the filename is being set in the content-disposition line.

The trickiest part is that I am totally unable to reproduce the errors myself; Firefox, IE, Opera and humble wget all download the zip fine and it's totally intact/well-formed. I'm totally pulling my hair out :(

I'd appreciate some help debugging, so if you don't mind downloading this zip file and - provided you get a corrupt file - posting your browser/OS/zip utility, I'd really appreciate it. Otherwise I'll just presume no news is good news and ignore it :)
 
Tried adding those. It's the weirdest bug I've ever come across though; one user said this:

"I am presently in LA; here is where I downloaded a corrupt file. When I remotely connected to a computer in Chicago a few minutes ago, I downloaded the file uncorrupted. Interesting."

:(
 
Back
Top Bottom