I am using online invoice system, and their API allows me to download PDF invoice in form of string which is zipped pdf encoded in base64.
I decode this string with base64_decode(), then I save it as file: file_put_contents('temp/soubor.zip', $data);
Now if I want to open this zip file in windows it is ok. But I want to extract it via php and if I call:
$zip = new ZipArchive;
if ($zip->open('temp/soubor.zip') === TRUE) {
print_r($zip->statIndex(0));
$zip->close();
}
I get
Array ( [name] => zipEntryName [index] => 0 [crc] => 1906707552 [size] => -1 [mtime] => 1358774308 [comp_size] => -1 [comp_method] => 8 )
Everything is fine except size - which is -1, and that's a huge problem because it won't extract anything.
And now interesting thing: If I open the zip file in winRar, choose repair archive, and open repaired zip file in my script, I get correct size and file can be correctly extracted. btw archived file is just 260kB.