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
75%Fix Rate
84%Confidence
1Evidence
2024-01-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 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.phpWorkarounds
-
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.
-
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.
中文步骤
Validate the ZIP file using 'unzip -t' on the command line before processing, and request a fresh upload from the user if it fails.
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:
-
95% fail
Increasing PHP's memory_limit does not fix CRC errors, as the issue is with file integrity, not memory.
-
90% fail
Re-uploading the same corrupted file will produce the same CRC error.
-
80% fail
Setting ZipArchive::CHECKCONS to false may bypass the check but could lead to incomplete or corrupted extracted data.