
PM75 - 2008-07-11 06:04:26
I created a function for this class, to force download of the archive without having to save it to disk first. Add the following function to the class:
public function dowloadZippedFile($archiveName) {
$headerInfo = '';
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// Security checks
if( $archiveName == "" ) {
echo "<html><title>Photo Directory - Download </title><body><BR><B>ERROR:</B> The download file was NOT SPECIFIED.</body></html>";
exit;
}
elseif ( ! file_exists( $archiveName ) ) {
echo "<html><title>Photo Directory - Download </title><body><BR><B>ERROR:</B> File not found.</body></html>";
exit;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=".basename($archiveName).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($archiveName));
print $this->getZippedfile();
}