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'] ]) : 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.
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']
-
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.