Click to See Complete Forum and Search --> : Header Zip Problem


albyh
01-16-2008, 10:19 AM
Hi,

I'm currently writing a digital webstore and am having some trouble sending full albums to the user as a ZIP file. The code below works fine for the single MP3's but when a ZIP is downloaded it ends up corrupt. I've been scratching my head for ages on this one so any help would be greatly appreciated.


if ($single == TRUE){
$filename = "$artist - $name.mp3";
$myFile = "/var/www/mp3/$artist - $name.mp3";
$mm_type="application/octet-stream";
} else {
$filename = "$artist - $name.zip";
$myFile = "/var/www/mp3/$artist - $name.zip";
$mm_type="application/zip";
}

header("Cache-Control: public, must-revalidate");
header("Pragma: public");
header("Content-Type: " . $mm_type);
header("Content-Length: " . filesize($myFile));
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");

readfile($myFile);