R
ragtek
Guest
Hi, i'm trying to create a zip archive on the fly
The script creates the archive and adds the text.txt to the archive,
my logger shows that the directory content should be added, but it's not in the archive
Anybody know what's the problem?
PHP:
# $zip = new Ragtek_Helper_ZipArchive();
$zip = new ZipArchive();
$filePath = 'd:\addon.zip';
$resource = $zip->open( $filePath, ZipArchive::CREATE );
if ($resource === TRUE)
{
$zip->addFromString( 'test.txt', 'Hier steht ein beliebiger Text.' );
$directory = XenForo_Autoloader::getInstance()->getRootDir() . '\Ragtek\\' . substr($addOnId, 6) . '\\';
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
while ($files->valid())
{
$key = $files->key();
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
Ragtek_Helper_Log::getInstance()->log($key . ' added');
$files->next();
}
# $zip->addDirectory($directory);
$zip->close();
The script creates the archive and adds the text.txt to the archive,
my logger shows that the directory content should be added, but it's not in the archive
Anybody know what's the problem?