PHP code example of stolentine / zip-partial-reader
1. Go to this page and download the library: Download stolentine/zip-partial-reader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stolentine / zip-partial-reader example snippets
use Stolentine\ZipPartialReader\ZipPartialReader;
$zip = ZipPartialReader::openUrl('https://example.com/foo.zip');
$path = '/var/www/files/';
$pathName = '/var/www/files/fooBazBar.xml';
$filePathName = 'baz/bar.xml';
foreach ($zip->getFiles() as $file) {
if (str_starts_with($file->name, $filePathName)) {
$zip->extractToDir($file, new SplFileInfo($path));
// or
$zip->extractToFile($file, new SplFileInfo($pathName));
}
}