Looking for a bit of help. Ive run in to an issues when downloading a zip file I just created in php. I seem to always get Network Failed or invalid file. After looking around I came across a few solutions such as trying sending in chunks and ob_clean(); flush();
but neither worked for me. Am I missing anything important here? I think my header tags are correct. Heres what I got:
$zip = new ZipArchive;
if ($zip->open(($fileloc . "registration/test_new.zip"), ZipArchive::CREATE) === TRUE){
foreach ($_POST["downloaddocs"] as $key => $value) {
$zip->addFile(($fileloc."registration/allreddocs/".$value),$value);
}
$zip->close();
}
$zipfile = $fileloc . "registration/test_new.zip";
if (file_exists($zipfile)) {
header('Pragma: public');
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
header("Content-type: application/zip");
header('Content-Disposition: attachment; filename=test');
header('Content-Length: ' . filesize($zipfile));
ob_clean();
flush();
readfile($file);
} else {
print "nofile";
}
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire