No matter what I try, it is always empty or corrupted.
here is the code which returns a zip without any content:
Code: Select all
<?php
ob_start();
$path = '/site/site_files/download_files/test.zip';
$mm_type="application/zip";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
ob_end_clean();
readfile($path); // outputs the content of the file
exit();
?>
This is the second time I've posted on these forums because I tend to google the answer, I much rather spend hours and hours trying and testing to resolve my problems rather than posting a noob question (designer with very basic php skills) and wasting the time of so many who help others, but in this case, I just can't seem to get that zip downloaded correctly.
I have tested on Linux, OSx, WIn, and every browser from IE7 to 9, current versions of FF, Op, Saf, Chrome all the same, the file downloads, it even extracts, but there isn't anything in it. I have made sure several times, the path is correct and that the zip actually DOES contain a test file. Have also tried to use http in the file path, does the same thing.
Any help, as always, is highly appreciated