extract a zip to folder

PHOTO EMBED

Wed May 20 2020 19:53:26 GMT+0000 (Coordinated Universal Time)

Saved by @isalmanhaider@gmail.com #php

// assuming file.zip is in the same directory as the executing script.
$file = 'file.zip';

// get the absolute path to $file
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);

$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
  // extract it to the path we determined above
  $zip->extractTo($path);
  $zip->close();
  echo "WOOT! $file extracted to $path";
} else {
  echo "Doh! I couldn't open $file";
}
content_copyCOPY

Very handy code snippet! Some servers where you don't have the option to upload 100mb + files from the Cpanel or file manager, so upload a zip via FileZilla and then this script into extract.php putting it on a same level as of the zip. and execute it through the browser. It will extract the zip to the folder.