I am trying to extract the zip file in PHP the path I am providing plus the filename each and everything is 100% correct but still when I run the script it returns Err_Code 19 . File is not a zip Archive. The main module is that it downloads the zip file from google drive and then extract it and restores the whole site when I run the same module and download file from FTP or Dropbox or S3 it worked perfectly fine but when downloaded it from drive it starts giving me this error Here is the code I am trying.
$extractTo = wp_upload_dir()['basedir'];
$zip = new ZipArchive;
$res = $zip->open($zipFile);
if (is_resource($res)) {
echo 'HERE'; exit;
$zip->extractTo($extractTo);
$zip->close();
$dirs = array_filter(glob($extractTo . '/*'), 'is_dir');
foreach ($dirs as $dir) {
$fileName = basename($dir);
if ($fileName == 'themes') {
$pathFrom = $extractTo . '/themes';
$pathTo = get_home_path() . 'wp-content\themes';
Helper::moveDirectories($pathFrom, $pathTo);
Helper::removeDirectories($pathFrom);
} else if ($fileName == 'files') {
$pathFrom = $extractTo . '/files';
$pathTo = get_home_path() . 'wp-content\uploads';
Helper::moveDirectories($pathFrom, $pathTo);
Helper::removeDirectories($pathFrom);
} else if ($fileName == 'plugins') {
$pathFrom = $extractTo . '/plugins';
$pathTo = get_home_path() . 'wp-content\plugins';
Helper::moveDirectories($pathFrom, $pathTo);
Helper::removeDirectories($pathFrom);
} else if ($fileName == 'database') {
$pathFrom = $extractTo . '/database';
$filename = array_filter(glob($pathFrom . '/*'));
Helper::DelDatabse();
Helper::importDatabase($filename[0]);
Helper::removeDirectories($pathFrom);
}
}
echo 'Done!';
} else {
echo $res;
}
Don't know what is the issue or what might be causing this strange issue any help would be appreciated. Thank you.
Possible Duplication
But none of the solution is working.