php-zip icon indicating copy to clipboard operation
php-zip copied to clipboard

Save zip without compression

Open GDenisC opened this issue 2 years ago • 5 comments

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 */;

GDenisC avatar Mar 04 '23 16:03 GDenisC

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.

odan avatar Mar 05 '23 19:03 odan

i mean all files (with directories), because i need $zip->openFile($fileName);

GDenisC avatar Mar 06 '23 08:03 GDenisC

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?

odan avatar Mar 06 '23 09:03 odan

Yes, I want to open a zip file with a lot of compressed files, export it, change some files and save as uncompressed zip.

GDenisC avatar Mar 06 '23 16:03 GDenisC

You can already do this with the existing methods.

odan avatar Mar 06 '23 19:03 odan