How can you create a ZIP file using the fopen() wrapper? This is obviously not the way:
<?php
if( class_exists('ZipArchive') ){
echo 'Class ZipArchive exists, generating file...' . PHP_EOL;
$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip', 'w');
if($fp){
fwrite($fp, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.');
fclose($fp);
echo 'Done' . PHP_EOL;
}else{
echo 'Could not open file' . PHP_EOL;
}
}else{
echo 'Class Zip is not available' . PHP_EOL;
}
... because all I get is:
Class ZipArchive exists, generating file...
Warning: fopen(zip://C:\tmp/test.zip) [http://es.php.net/function.fopen]: failed to open stream: operation failed in C:\tmp\test.php on line 6
Could not o开发者_如何学Cpen file
I finally assumed that the claim that zip:
wrapper supports writing was a documentation error and reported it as such. The bug report was accepted and fixed.
精彩评论