ZipArchive下载失败

I'am using ZipArchive class to generate and download zipFile. It must be work on php 5.2.14. It works perfectly on php 5.3.x with this code:

$filename = "test.zip";
$zip = new ZipArchive();
$opened = $zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);

$zip->addFromString(...,...);
$zip->close();

header('Content-disposition: attachment; filename='.$filename);
header('Content-type: application/zip');
readfile("$filename");
exit();

On php 5.2.14 it produces an empty (0 byte size) zip file. If I remove the exit() instruction it produces a corrupted zip file.

Solutions?

i'm posting a portion of my program which use the ZipArchive Class

$this->licensePlate = "AA000AA";
$this->fileName = "path/to/file/tmp.zip";
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="Foto_'.$this->licensePlate.'.zip"');
readfile($this->fileName);

Are you sure you're actually adding the files to the ZipArchive? Are you sure you're actually have the permission to create the ZipArchive?