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
4
votes
2 answers

MacOS Catalina: Class 'ZipArchive' not found

Upgrading to 10.15.1 (19B88) Mac OS Catalina broke my PHP 7.3.9 development environment. $zip = new \ZipArchive; Yields Exception 'Error' with message 'Class 'ZipArchive' not found' zip and unzip are installed at Terminal command line. Trying to…
Lookahead
  • 41
  • 1
  • 5
4
votes
1 answer

Compression/Decompression library for the iPhone and Xcode 4

I have been working on a project that requires downloading a zipped file off a server, and am stuck trying to uncompress it on the iPhone. There appear to be a number of solutions such as LiteUnzip , ZipArchive and a few others but none so…
jakev
  • 2,815
  • 3
  • 26
  • 39
4
votes
1 answer

C# create zip file using zip archive System.IO.Compression

Here is the functionality I want to achieve Write a JSON file. Write a PDF file. Create an archive for these two files I am using the System.IO.Compression ZipArchive to achieve this. From the documentation, I have not found a good use case for…
Nikhilesh
  • 1,711
  • 2
  • 15
  • 19
4
votes
2 answers

PHP - ZipArchive() permission issues with clean up

I keep having - I think permission issues - with unzipping a file (this part goes OK) and moving content to write folder. I am running simple code: $zip = new ZipArchive( ); $x = $zip->open( $file ); if ( $x === true ) { $zip->extractTo(…
bensiu
  • 24,660
  • 56
  • 77
  • 117
4
votes
1 answer

How to update Libzip to 1.2 on ubuntu 18.04 and PHP 7.2

I want to use ZipArchive::setEncryptionName on Ubuntu server 18.04.1 with PHP 7.2.7 Problem is that setEncryptionName need Libzip version at least 1.2 default configuration from PHP info: Zip version 1.15.2 Libzip version 1.1.2 I don't know how to…
Roman
  • 41
  • 1
  • 3
4
votes
1 answer

PHP can't access newly created zip file

Im using Laravel 5.2 and Zipper to create ZIP archive in a fly and download it by user. I think this problem is generall not strictly related to Laravel or Zipper. Steps: User click link download_all. First php script create archive. Next the same…
Adiasz
  • 1,624
  • 1
  • 12
  • 21
4
votes
1 answer

BitmapEncoder Save Not Supported

I have the following code and I can't see anything wrong, any ideas on what the problem could be? private static string SaveBaseImage( ZipArchive arc, DBImage image, int imageIndex ) { using (var mem = new MemoryStream(image.Data)) { …
MikeT
  • 5,398
  • 3
  • 27
  • 43
4
votes
1 answer

Ziparchive unable to open zip file only in PHP

I'm trying to unzip a file using PHP ZipArchive class but when I try: $file = '/path/to/zip/file.zip'; $zip = new ZipArchive(); $res = $zip->open($file, ZipArchive::CHECKCONS); The result is ZipArchive::ER_INCONS (Zip archive inconsistent) Now,…
jdubu423
  • 405
  • 4
  • 18
4
votes
4 answers

Keep the modified date of files extracted from the ZIP using PHP ZipArchive

I am using ZipArchive to extract files from ZIP. Here is the code I am using $zip = new ZipArchive; $res = $zip->open($file); if ($res === TRUE) { $zip->extractTo('test/'); $zip->close(); } It works fine but the last modified date of…
Badal
  • 3,738
  • 4
  • 33
  • 60
4
votes
1 answer

Add SQLite database directly to Zip file

I am trying to create an SQLite database in memory and then add it directly to a zip file I have created. So far I can create the zip file using the ZipArchive and ZipFile classes. However, I cannot find a way to add an SQLite database I have…
Michael Murphy
  • 1,921
  • 2
  • 18
  • 21
4
votes
1 answer

ZipArchive addFromString doesn't work properly on Windows

I have a server whch runs a little app that we use to create .docx. It worked perfectly on an old server but I had to move it on another one and now it has a great problem: when I run my php script - based on PHPWord - the output files are broken…
luca3003
  • 109
  • 8
4
votes
1 answer

Google app engine php zip extension

I am using Google app engine and I want to create a zip archive using the zip extension which is supported in the current version. The problem is that every time i call ZipArchive::close it returns false and ZipArchive::getStatusString returns…
copper
  • 63
  • 5
4
votes
1 answer

Fatal error: Class 'ZipArchive' - not found when using PHPUnit

I have refactored some PHP code and putting it through a series of PHPUnit classes. I get the above Fatal Error when running PHPUnit (3.7.28) on it (through console). PHP version is 5.4.6-1ubuntu1.4 (cli). I know the Zip class is working and…
peedeeaay
  • 116
  • 1
  • 7
4
votes
1 answer

php - extract files from folder in a zip

I have a zip file containing one folder, that contains more folders and files, like this: myfile.zip -firstlevel --folder1 --folder2 --folder3 --file1 --file2 Now, I want to extract this file using PHPs ZipArchive, but without the "firstlevel"…
Harmageddon
  • 61
  • 1
  • 4
4
votes
5 answers

Cannot open zip file in Windows Explorer which generated by PHP Zip Archive

When I trying to open my zip file which is generated by PHP Zip Archive, there is an alert showing "Windows cannot open the folder. The Compressed (zipped) Folder 'filename' is invalid." error opening in Windows Explorer. But I can open the file…
Ywis
  • 180
  • 1
  • 4
  • 13