I'm having trouble extracting file some files from zip using ZipArchive
Here is my code
$pp_saved_zip_archive = "$extract_path/archive.zip";
$zip = new ZipArchive;
$res = $zip->open($pp_saved_zip_archive, ZipArchive::CREATE);
$zip->extractTo($previews_path);
$zip->close();
I get two errors/warnings in this code
PHP Warning: ZipArchive::extractTo(): Invalid or uninitialized Zip object in ...
PHP Warning: ZipArchive::close(): Invalid or uninitialized Zip object in ...
If I check for $res
variable it returns 19
, which is weird, it should be either TRUE
or FALSE
My paths are correct, so it's not a path problem. This is done behind WordPress, I've tried $_SERVER['DOCUMENT_ROOT']
and ABSPATH
to no avail. I also tried with different zip files, still no luck.