php-zip
php-zip copied to clipboard
Save zip without compression
| Q | A |
|---|---|
| Library version(s) affected: | 4.01 |
| PHP version(s): | 8.1.2 |
| OS (with bit depth): | Windows 10 64-bit |
Description
How save zip without compression (all files)?
How to reproduce
$zip = new ZipFile();
$zip->openFile($fileName);
/* some code */
$zip->setCompressionMethodEntry(what do you mean with entry?, ZipCompressionMethod::STORED)->/* etc */;
According to the documentation:
$zip->addFile($file, $entryName, \PhpZip\Constants\ZipCompressionMethod::STORED); // No compression
or
$zip->addFromString('file', 'content', \PhpZip\Constants\ZipCompressionMethod::STORED);
what do you mean with entry?
The $entryName is the filename within the zip archive.
i mean all files (with directories), because i need $zip->openFile($fileName);
The openFile method is to open a ZIP file and can be used in combination with the extractTo method to extract files from that ZIP file.
Are you trying to "change" an existing ZIP file to an ZIP file with uncompressed content? Can please add more details about your specific use-case?
Yes, I want to open a zip file with a lot of compressed files, export it, change some files and save as uncompressed zip.
You can already do this with the existing methods.