# ZipArchive::extractTo()：无法解压 zip 存档 '/tmp/upload_abc123.zip'：ZipArchive::ER_CRC 错误，位于 /var/www/app/src/Import/ZipImporter.php 第 42 行

- **ID:** `php/zip-archive-corrupt-archive`
- **领域:** php
- **类别:** data_error
- **错误码:** `ZipArchive::ER_CRC`
- **验证级别:** ai_generated
- **修复率:** 70%

## 根因

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

## 版本兼容性

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

## 解决方案

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

## 无效尝试

- **** — CRC errors are data integrity issues, not resource limits. Increasing limits won't fix corrupted data. (95% 失败率)
- **** — If the source file is corrupt on disk, re-uploading the same file yields the same CRC error. (80% 失败率)
