php
data_error
ai_generated
true
ZipArchive::extractTo():提取 zip 归档 '/tmp/upload_abc123.zip' 失败:ZipArchive::ER_CRC 错误,位于 /var/www/app/src/Export/ZipExporter.php 第 22 行
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%修复率
84%置信度
1证据数
2024-01-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| PHP 8.1 | active | — | — | — |
| PHP 8.2 | active | — | — | — |
| PHP 8.3 | active | — | — | — |
根因分析
ZIP 归档存在 CRC32 校验和不匹配,表明在上传、下载或存储过程中文件损坏。
English
The ZIP archive has a CRC32 checksum mismatch, indicating file corruption during upload, download, or storage.
官方文档
https://www.php.net/manual/en/ziparchive.extractto.php解决方案
-
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.
无效尝试
常见但无效的做法:
-
95% 失败
Increasing PHP's memory_limit does not fix CRC errors, as the issue is with file integrity, not memory.
-
90% 失败
Re-uploading the same corrupted file will produce the same CRC error.
-
80% 失败
Setting ZipArchive::CHECKCONS to false may bypass the check but could lead to incomplete or corrupted extracted data.