php data_error ai_generated true

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

ID: php/ziparchive-crc-error

Also available as: JSON · Markdown · 中文
75%Fix Rate
84%Confidence
1Evidence
2024-01-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
PHP 8.1 active
PHP 8.2 active
PHP 8.3 active

Root Cause

The ZIP archive has a CRC32 checksum mismatch, indicating file corruption during upload, download, or storage.

generic

中文

ZIP 归档存在 CRC32 校验和不匹配,表明在上传、下载或存储过程中文件损坏。

Official Documentation

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

Workarounds

  1. 80% success Validate the ZIP file using 'unzip -t' on the command line before processing, and request a fresh upload from the user if it fails.
    Validate the ZIP file using 'unzip -t' on the command line before processing, and request a fresh upload from the user if it fails.
  2. 85% success Use ZipArchive::open() with ZIPARCHIVE::CHECKCONS flag to detect corruption early and provide a user-friendly error message.
    Use ZipArchive::open() with ZIPARCHIVE::CHECKCONS flag to detect corruption early and provide a user-friendly error message.

中文步骤

  1. Validate the ZIP file using 'unzip -t' on the command line before processing, and request a fresh upload from the user if it fails.
  2. Use ZipArchive::open() with ZIPARCHIVE::CHECKCONS flag to detect corruption early and provide a user-friendly error message.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Increasing PHP's memory_limit does not fix CRC errors, as the issue is with file integrity, not memory.

  2. 90% fail

    Re-uploading the same corrupted file will produce the same CRC error.

  3. 80% fail

    Setting ZipArchive::CHECKCONS to false may bypass the check but could lead to incomplete or corrupted extracted data.