Menu

## Mime
in package

Mime.php : 18

Class responsible for handling MIME types and file extensions.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

check() : bool
  Check if the MIME type matches the accepted types.
get() : string|array<string|int, mixed>|null
  Get the MIME type for a file extension.
getAccept() : string
  Get the accept string for input of type "file".
getMimeTypes() : array<string|int, mixed>
  Get an array of MIME types.

### Methods

#### check()

Mime.php : 61

Check if the MIME type matches the accepted types.

`public static check(array<string|int, mixed> $typies, string $mime) : bool`

Used for validating uploaded files.

##### Parameters

$typies : array<string|int, mixed>

  The accepted file types.

$mime : string

  The MIME type to check, usually obtained from the uploaded file.

##### Tags

assert

  (array('jpg','gif','png'), 'image/png') [==] true

##### Return values

bool —

True if the MIME type matches any of the accepted types, false otherwise.

#### get()

Mime.php : 32

Get the MIME type for a file extension.

`public static get(string|array<string|int, mixed> $exts) : string|array<string|int, mixed>|null`

Returns null if not found.

##### Parameters

$exts : string|array<string|int, mixed>

  The file extension(s).

##### Tags

assert

  (array('jpg','gif','png')) [==] array('jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png')

assert

  ('jpg') [==] 'image/jpeg'

##### Return values

string|array<string|int, mixed>|null —

The MIME type(s) corresponding to the given extension(s).

#### getAccept()

Mime.php : 83

Get the accept string for input of type "file".

`public static getAccept(array<string|int, mixed> $typies) : string`

Returns a comma-separated string of MIME types.

##### Parameters

$typies : array<string|int, mixed>

  The file types.

##### Tags

assert

  (array('jpg','gif','png')) [==] "image/jpeg,image/gif,image/png"

##### Return values

string —

The accept string for the given file types.

#### getMimeTypes()

Mime.php : 100

Get an array of MIME types.

`private static getMimeTypes() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

An array of MIME types.

## Search results