I'm trying to use the PHP
ZipArchive class, but I can't seem to get it to work. It always has a status of 0, and the folder is never created. The script is uploaded
here.
PHP code:
print("<pre>Result of file system search:\n\n");
print_r(glob("{level,scenario}s/*/*.mf{l,s}", GLOB_BRACE
));
print("\nOpening archive...\n");
$zip = new ZipArchive
();
$zip -> open("files.zip", ZIPARCHIVE
::CREATE) or
die("Error: could not open archive.");
print("\nLoading levels through iterator...\n");
$iterator = new RecursiveIteratorIterator
(new RecursiveDirectoryIterator
("levels/"));
foreach ($iterator as $key => $value)
{
print("| ".$key." => ".$value."\n");
$zip -> addFile(realpath($key), $key) or
die ("Error: could not add file: ".$key);
}
print("\nLoading scenarios through iterator...\n");
$iterator = new RecursiveIteratorIterator
(new RecursiveDirectoryIterator
("scenarios/"));
foreach ($iterator as $key => $value)
{
print("| ".$key." => ".$value."\n");
$zip -> addFile(realpath($key), $key) or
die ("Error: could not add file: ".$key);
}
print("\nTotal number of files: ".$zip -> numFiles."\nArchive status: ".$zip -> status."</pre>");
$zip -> close();