I'm trying to extract a csv file from a zip and I'm always getting an integer instead of a boolean in the following code.
$zip = "path_to_zip/zip.zip";
if (file_exists($zip))
{
echo "Extracting";
$z = new ZipArchive;
$res = $z->open($zip);
var_dump($res);
if ($res === TRUE)
{
$z->extractTo("my_path/");
$z->close();
}
else
{
echo "failed";
}
}
The zip file exists on the specified location as "Extracting" is displayed but then the $res variables return 19 as an integer and the script ends up with echoing "failed".
If I skip the line with $res === TRUE, I get the following message:
Warning: ZipArchive::extractTo(): Invalid or uninitialized Zip object
Do you see what's wrong with the object?