Ne-Lexa / php-zip

PhpZip is a php-library for extended work with ZIP-archives.
MIT License
491 stars 60 forks source link

Save zip without compression #94

Open GDenisC opened 1 year ago

GDenisC commented 1 year ago
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 */;
odan commented 1 year ago

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.

GDenisC commented 1 year ago

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

odan commented 1 year ago

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?

GDenisC commented 1 year ago

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

odan commented 1 year ago

You can already do this with the existing methods.