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
2
votes
1 answer

Powershell read XML file content in a nested zip file

I'm facing a problem related to nested zip files in powershell. Currently I have a zip file that contains a second zip file. Inside this second zip file I have a XML file that contains some business data that I need to read and access without…
Samou Mc
  • 43
  • 1
  • 5
2
votes
1 answer

ZipArchive::addFile() creates zip files with tree structure in Windows but flattened in Linux

I used PHP's ZipArchive library to create a zip file to easily transfer images for some e-shop synchronization service from a desktop to the web server of the e-shop. The script I used to create the zip is below: function compress(string $path) { …
Faye D.
  • 833
  • 1
  • 3
  • 16
2
votes
1 answer

PHPOffice/Word - Error when generate multiple files from template

I'm using the PHPOffice/Word package to generate word files from template and i use Laravel 5.8 version running on PHP Server 7.3.29. The generation works pretty good when i download only one word document, but when i want to generate multiple word…
Hippo
  • 65
  • 8
2
votes
1 answer

Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory

We have code to upload a zip file, at the start of the process if the zip file contains __MACOSX folder in the zip it will strip these folders/files from the zip and pass the file bytes on. The issue we're having is that further down the chain if we…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
2
votes
1 answer

Unexpected end of archive on a ZIP file in c#

I am trying to zip a text file and split it into chunks(byte[]) in the console application. public List CreateChunks(string fileName, string txtFilePath) { long chunkSize = 100 * 1000;//100kb var fileChunks = new…
Dinesh
  • 411
  • 6
  • 19
2
votes
1 answer

NET Core throws InvalidDataException when unzipping ZIP file, Windows Explorer unzips successfully

I'm trying to unzip a nested zip file, but I'm getting a InvalidDataException. When I try unzipping the same file in Windows Explorer, it unzips successfully. Why would Windows Explorer be able to unzip it and not the .NET Core Compression…
Jamie Lester
  • 848
  • 9
  • 20
2
votes
2 answers

Rust help extracting ZIP contents

I have a complex file read issue....I have a need to read a DOCX file with an embedded file system, extract a ZIP file, and peruse the ZIP file's internal directory to extract the actual files I need. I already have written this code in Java…
flyinggreg
  • 79
  • 1
  • 9
2
votes
0 answers

ZipArchive - addFile won't work

Situation I have a .zip file. In this .zip is a folder "dist/", in the folder "dist/" are 2 things: 1) another folder "lib/" 2) a jar-file I open the .zip and extract the dist/jar-file. A "new" folder will appear on my disk "dist" with the jar in…
Rob
  • 25
  • 7
2
votes
0 answers

create zip with images contained in an array in a wordpress page

I have files that are already located on my server. I have created an array that has the full path to the files. The file names resolve correctly. $files = array($sm_image1ok, $sm_image2ok, $sm_image3ok, $sm_ambianceok, $sm_planok, $sm_mobilierok,…
Rich
  • 107
  • 1
  • 13
2
votes
0 answers

Getting Error System.IO.InvalidDataException: 'End of Central Directory record could not be found

I have a method which was working fine with PDFs has started giving errors, I checked in TFS - I didn't find any changes in that part of the method, I am getting the error: System.IO.InvalidDataException: 'End of Central Directory record could …
2
votes
3 answers

ZipArchive ignores date_default_timezone_set for files placed in the .zip file

I'm running PHP 7.0.33 on a Linux server (shared web hosting). With date_default_timezone_set('Europe/Rome'); I can properly set my timezone. echo date('Y-m-d H:i:s'); shows the correct date-time. But the files added in a .zip with ZipArchive obtain…
user2342558
  • 5,567
  • 5
  • 33
  • 54
2
votes
0 answers

How to Select Specific Directories to Zip in Root Directory

I have several hosting accounts with a WordPress install in the Root directory and several addon domains with Wordpress installed in sub-directories. I am looking to compress only the Wordpress install in the root and think looking for wp-admin,…
KenMc
  • 23
  • 1
  • 3
2
votes
1 answer

Unable to extract zip files created from Java

I have written a small Java programme as follows to create a zip archive using a provided directory. import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import…
Kasun Siyambalapitiya
  • 3,956
  • 8
  • 38
  • 58
2
votes
1 answer

ZIP a folder with PHP preserving file properties

I use PHP ZIPArchive to create zip file from folder and user doesn't want to change the original file created date when download. my code is below and is there any option that helps to keep the file created date? function zipData($source,…
Thameera
  • 33
  • 4
2
votes
0 answers

PHP password protected ZipArchive not opening on OS X or prompting the user for a password

In php 7.2.0 I create a zip that is password protected and encrypted per file like suggested in the php docs. This feature works well and after the zip is downloaded to the client on windows the user is prompted to fill-in a password and the…