# ZipArchive::extractTo()：提取 zip 归档 '/tmp/upload_abc123.zip' 失败：ZipArchive::ER_CRC 错误，位于 /var/www/app/src/Export/ZipExporter.php 第 22 行

- **ID:** `php/ziparchive-crc-error`
- **领域:** php
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |
| PHP 8.3 | active | — | — |

## 解决方案

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.
   ```

## 无效尝试

- **** — Increasing PHP's memory_limit does not fix CRC errors, as the issue is with file integrity, not memory. (95% 失败率)
- **** — Re-uploading the same corrupted file will produce the same CRC error. (90% 失败率)
- **** — Setting ZipArchive::CHECKCONS to false may bypass the check but could lead to incomplete or corrupted extracted data. (80% 失败率)
