Oihana PHP

assertZip.php

Table of Contents

Functions

assertZip()  : bool
Validates that a file is a zip archive.

Functions

assertZip()

Validates that a file is a zip archive.

assertZip(string $filePath[, bool $strictMode = false ]) : bool
Parameters
$filePath : string

Path to the file to validate.

$strictMode : bool = false

If true, performs deep validation using file contents (see validateZipStructure()). If false, only checks the extension and the basic MIME type.

Tags
throws
FileException

If the file does not exist or cannot be read.

author

Marc Alcaraz (ekameleon)

since
1.2.0
example

Basic validation using file extension and MIME type:

$isValid = assertZip('/path/to/archive.zip');

Strict validation with file content inspection:

$isValid = assertZip('/path/to/archive.zip', true);
Return values
bool

True if the file is a valid zip archive, false otherwise.

On this page

Search results