Questions tagged [ziparchive]

ZipArchive is a PHP extension for manipulating zip compressed archives.

ZipArchive provides procedural and object oriented approaches for creating, extracting and editing zip archives. The php manual provides a full documentation for both approaches, while on wikipedia history and technique of zip compression is covered.

818 questions
7
votes
3 answers

PHP ZipArchive is not adding any files (Windows)

I'm failing to put even a single file into a new zip archive. makeZipTest.php: open($destination,…
Jodes
  • 14,118
  • 26
  • 97
  • 156
7
votes
2 answers

ZipArchive extraction - single file

I have the following code: $ipaFile= '/path/file.ipa'; $iconFilePath = "Payload/myapp.app/AppIcon40x40@2x.png"; // the pathway to my image file if the ipa file is unzipped. $iconFile = "AppIcon40x40@2x.png"; $iconSaveFile = '/path/'; $zip = new…
Pete_1
  • 981
  • 3
  • 14
  • 23
7
votes
1 answer

ZipArchive php Class - Is it built-in to PHP?

Ok, just wondering on the versions of PHP that this class is built into. And if they are built into all platforms (OS's). I'm wanting an approach to search through a zip file and place files using file_put_contents in different filepaths within…
SoLoGHoST
  • 2,673
  • 7
  • 30
  • 51
7
votes
2 answers

Weird behaviour with ZipArchive() adding null bytes to archive

I have a simple Zip creation script that copies a load of files into a single directory and then creates a .zip file from that directory. This approach sounds simple, however the archives it produces have issues opening. At first I was confused…
Dave
  • 3,280
  • 2
  • 22
  • 40
7
votes
4 answers

ZipArchive PHP adding only files without directories from the whole path

Fellow coders: Hate to ask this question, as it was, I belive correctly answered two times: Here And here So the problem is: when unzipping the downloaded 'file.zip', after unzipping, it contains all the folders from the path, even tough I…
Igor L.
  • 3,159
  • 7
  • 40
  • 61
7
votes
8 answers

Getting corrupted or empty zip by ZipArchive php

I am getting zip file downloaded by following code without any error but the downloaded zip file is empty or corrupted and size is always about 200 Bytes. i.e. I cannot open that zip file. Also ZipArchive::getStatusString() is also showing "No…
Durgesh Suthar
  • 2,914
  • 4
  • 19
  • 22
6
votes
1 answer

Setting permissions in ZipArchive

I have a Zip file. I open it with ZipArchive php library, and add a dir and a file in it. When I extract it with ubuntu's default unarchiver everything works as expected. But when I extract it with any unarchiver on OS X Snow Leopard (tried with the…
mimrock
  • 4,813
  • 8
  • 32
  • 35
6
votes
1 answer

Using ZipArchive with PHP 8 and temporary files

PHP 8 changes how the "open" of a ZIP archive works and it is noted that: Using empty file as ZipArchive is deprecated. Libzip 1.6.0 do not accept empty files as valid zip archives any longer. In the test code below the opening of the ZIP file…
Dave
  • 5,108
  • 16
  • 30
  • 40
6
votes
2 answers

How to access a file in zipapp

I've got a simple Python zipapp built with the following command: python -m pkg/ -c -o test -p '/usr/bin/python3' -m 'test:main' zipapp I would like to access the binary file from the script $ cat pkg/test.py def main(): with open('test.bin',…
HTF
  • 6,632
  • 6
  • 30
  • 49
6
votes
0 answers

StackoverFlowException When creating ZipArchive from within ZipArchive

I am attempting to recursively parse through a zip folder and any zip folders inside it to collect files using the following code: private IList _getFilesFromZip(ZipArchive zipArchive) { var returnFiles = new List(); …
jth41
  • 3,808
  • 9
  • 59
  • 109
6
votes
2 answers

Unable to install PHP zip archive with PHP 7.2

I am running into some issues installing the PHP zip archive and not sure how to fix this. I am running Ubuntu 18 with PHP 7.2 The error I receive in terminal is The following packages have unmet dependencies. php7.2-zip : Depends: php7.2-common (=…
userdrupa4356
  • 61
  • 1
  • 1
  • 4
6
votes
4 answers

What encoding does ZipArchive use to store file names inside the created archive?

I'm using the php ZipArchive class in order to generate a zip archive. I use the second parameter of the addFile method in order to set the name of the file in the archive (since the real file on disk has a different name). Some of the names must…
matei
  • 8,465
  • 1
  • 17
  • 15
6
votes
3 answers

PhpSpreadSheet Class ZipArchive not found Error

I've just downloaded PhpSpreadsheet package via composer and I tried to generate an Excel spreadsheet. But all I get is an error "Class ZipArchive not found ". I work on Windows. In my localhost it is correctly generating excel. My localhost php…
Ambili Bijesh
  • 69
  • 1
  • 2
6
votes
1 answer

ZipArchive, I need to create new file and overwrite existing

I am using php ZipArchive and I have run into a simple problem. I need to create new file and if there is existing file with that name I need to overwrite it. My problem is this, if I use this code if ($zip->open($packageFileName,…
niko craft
  • 2,893
  • 5
  • 38
  • 67
6
votes
0 answers

C# ZipArchive "End of Central Directory record could not be found"

I created a BizTalk Custom Pipeline Component, which zips all message parts into a zip stream. After some fails I created the following test method in a separate test project. Basically I get a XML file which contains a filename and an UUID which I…
Mario
  • 978
  • 2
  • 11
  • 31
1 2
3
54 55