zipFileInfo.php
Table of Contents
Functions
- zipFileInfo() : array{isValid?: bool, extension?: string, mimeType?: string|null, compression?: string|null, fileCount?: int|null, totalSize?: int|null}
- Retrieves detailed information about a zip archive file.
Functions
zipFileInfo()
Retrieves detailed information about a zip archive file.
zipFileInfo(string $filePath[, bool $strictMode = false ]) : array{isValid?: bool, extension?: string, mimeType?: string|null, compression?: string|null, fileCount?: int|null, totalSize?: int|null}
This function inspects the given zip file to determine its validity, MIME type, compression family, number of contained entries, and total uncompressed size.
It uses the ZipArchive class to count entries and sum their uncompressed sizes when the archive is valid.
Parameters
- $filePath : string
-
Absolute path to the zip archive file to inspect.
- $strictMode : bool = false
-
When true, enables strict validation of the zip structure via assertZip(). Default is false for a more lenient check.
Tags
Return values
array{isValid?: bool, extension?: string, mimeType?: string|null, compression?: string|null, fileCount?: int|null, totalSize?: int|null} —Returns an associative array keyed by ZipInfo with:
- isValid: Whether the file is a valid zip according to assertZip().
- extension: File extension (lowercase) extracted from the path.
- mimeType: MIME type detected via
finfo. - compression: CompressionType::ZIP when the MIME type is zip-like, otherwise CompressionType::NONE.
- fileCount: Number of entries inside the archive (if valid), otherwise null.
- totalSize: Sum of the uncompressed sizes (in bytes) of all entries (if valid), otherwise null.