I'm trying use the method getFromName($name) after I add the file via addFile($name) or addFromString($name, $contents).
On my case, I'm not loading an existing zip file, but I'm creating it in a temporary directory, by using open($name).
The file is added normally and when I do a var_dump() over ZipArchive instance, I get:
class ZipArchive {
public $status => int(0)
public $statusSys => int(0)
public $numFiles => int(1)
public $filename => string(45) "C:\Temp\Zip576D.tmp"
public $comment => string(0) ""
}
Note that $numFiles shows 1 correctly, and if I call close() it will create file normally with this file added. But if I use getFromName("test") it always returns false instead of file contents.
You can run the code example here: live example
<?php
$archive = new ZipArchive;
$archive->addFromString('test.bin', 'test');
$status = $archive->getFromName('test.bin');
echo $status === false ? 'FAIL' : 'SUCCESS: ' . $status;
?>