Answers for "unzip zip file from a folder php code"

PHP
2

unzip file php

$zip = new ZipArchive;
$res = $zip->open('file.zip');
if ($res === TRUE) {
  $zip->extractTo('/myzips/extract_path/');
  $zip->close();
  echo 'woot!';
} else {
  echo 'doh!';
}
Posted by: Guest on September-10-2020
4

php read zip file without extracting

As found as a comment on http://www.php.net/ziparchive:

The following code can be used to get a list of all the file names in a zip file.

<?php
$za = new ZipArchive(); 

$za->open('theZip.zip'); 

for( $i = 0; $i < $za->numFiles; $i++ ){ 
    $stat = $za->statIndex( $i ); 
    print_r( basename( $stat['name'] ) . PHP_EOL ); 
}
?>
Posted by: Guest on April-08-2021

Browse Popular Code Answers by Language