ZipArchive::ER_CRC php data_error ai_generated partial

ZipArchive::extractTo(): Failed to extract zip archive '/tmp/upload_abc123.zip': ZipArchive::ER_CRC error in /var/www/app/src/Import/ZipImporter.php on line 42

ID: php/zip-archive-corrupt-archive

Also available as: JSON · Markdown · 中文
70%Fix Rate
87%Confidence
1Evidence
2025-02-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.4 active
8.0 active
8.1 active
8.2 active
8.3 active

Root Cause

The ZIP archive is corrupt or incomplete, often due to a failed upload, truncated download, or disk write error, causing CRC checksum mismatches during extraction.

generic

中文

ZIP 存档损坏或不完整,通常由上传失败、下载中断或磁盘写入错误引起,导致解压时 CRC 校验和不匹配。

Official Documentation

https://www.php.net/manual/en/ziparchive.extractto.php

Workarounds

  1. 85% success Validate the ZIP file integrity before extraction using ZipArchive::open() with ZipArchive::CHECKCONS: $zip = new ZipArchive(); if ($zip->open($file, ZipArchive::CHECKCONS) !== true) { throw new Exception('Corrupt archive'); }
    Validate the ZIP file integrity before extraction using ZipArchive::open() with ZipArchive::CHECKCONS: $zip = new ZipArchive(); if ($zip->open($file, ZipArchive::CHECKCONS) !== true) { throw new Exception('Corrupt archive'); }
  2. 90% success Re-download or re-upload the ZIP file from the source, ensuring a complete transfer. Use checksums (e.g., MD5) to verify integrity.
    Re-download or re-upload the ZIP file from the source, ensuring a complete transfer. Use checksums (e.g., MD5) to verify integrity.
  3. 70% success Use a command-line tool like 'unzip -t archive.zip' to test the archive, then repair with 'zip -F archive.zip --out fixed.zip' if possible.
    Use a command-line tool like 'unzip -t archive.zip' to test the archive, then repair with 'zip -F archive.zip --out fixed.zip' if possible.

中文步骤

  1. Validate the ZIP file integrity before extraction using ZipArchive::open() with ZipArchive::CHECKCONS: $zip = new ZipArchive(); if ($zip->open($file, ZipArchive::CHECKCONS) !== true) { throw new Exception('Corrupt archive'); }
  2. Re-download or re-upload the ZIP file from the source, ensuring a complete transfer. Use checksums (e.g., MD5) to verify integrity.
  3. Use a command-line tool like 'unzip -t archive.zip' to test the archive, then repair with 'zip -F archive.zip --out fixed.zip' if possible.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    CRC errors are data integrity issues, not resource limits. Increasing limits won't fix corrupted data.

  2. 80% fail

    If the source file is corrupt on disk, re-uploading the same file yields the same CRC error.