$zip = new ZipArchive; if ($zip->open('my.zip') === TRUE) { $zip->addFile('/path/to/index.txt', 'newname.txt'); $zip->addFromString(basename($path), file_get_contents($path)); $zip->close(); header('Content-type: application/zip'); readfile('test.zip'); } else { echo 'failed'; }
Динамическое создание Zip – архива