I’m completely at a loss for explaining why this isn’t working. HELP!
$archive = "x.zip";
$zip = new ZipArchive();
$res = $zip->open($archive);
if ($res === 'TRUE') {
$unzip_success= $zip->extractTo('/temp/', "inscriptions.txt")
$zip->close();
}
- the target dir “temp” is “0777” permissions
- the code obtained from $res is “11” and not “TRUE” as required by the documentation on PHP.net
- note: must put the full url for $archive and the first argument of extractTo
if nothing works then check if your server is linux.
if its linux you can run unzip command to unzip your file via php’s system/exec function.
i.e
to extract specific file you can check man docs for unzip. many times due to server parameters zip library doesn’t work as expected in that cases i switch back to linux commands.