hasTarMimeType.php
Table of Contents
Functions
- hasTarMimeType() : bool
- Checks if a file has a tar-related extension.
Functions
hasTarMimeType()
Checks if a file has a tar-related extension.
hasTarMimeType(string $filePath[, array<string|int, string> $mimeTypes = [
'application/x-tar',
'application/tar',
'application/gzip',
'application/x-gzip',
'application/x-bzip2',
'application/bzip2',
'application/x-compressed-tar',
// What `finfo` reports for the two formats the system tar writes since 1.5.0,
// verified on real archives: `application/x-xz` and `application/zstd`.
'application/x-xz',
'application/zstd',
] ]) : bool
This function inspects the MIME type of the given file against a list of valid tar-related MIME types to determine if the file is a tar archive.
It is a thin wrapper around hasMimeType pre-configured with the common tar MIME types.
Parameters
- $filePath : string
-
Path to the file.
- $mimeTypes : array<string|int, string> = [ 'application/x-tar', 'application/tar', 'application/gzip', 'application/x-gzip', 'application/x-bzip2', 'application/bzip2', 'application/x-compressed-tar', // What `finfo` reports for the two formats the system tar writes since 1.5.0, // verified on real archives: `application/x-xz` and `application/zstd`. 'application/x-xz', 'application/zstd', ]
-
Optional list of valid tar MIME types. Defaults to common tar and compressed tar types:
- 'application/x-tar'
- 'application/tar'
- 'application/gzip'
- 'application/x-gzip'
- 'application/x-bzip2'
- 'application/bzip2'
- 'application/x-compressed-tar'
Tags
Return values
bool —True if the file exists and its MIME type matches one of the given tar MIME types.