webCOMAND

mime_type::get_info_from_filename()

Get information about a file format based on the filename, or the file contents if the file exists and the file extension is not recognized.  If the file extension is recognized, that will be used without verifying the file contents match.

Prototype

array get_info_from_filename(string $filename)

Parameters

  • filename - A filename or file path to a real file.  An absolute or relative path may be specified.

Return

An associative array with the following keys.

  • mime - The MIME Type string.
  • ext - The corresponding file extension.
  • text - TRUE if this MIME Type is a plain text format.
  • title - Human readable file format description.
  • short - Short human readable file format.

Example

// print information about the PDF file format
$filename = 'article.pdf';
$info = \io_comand_util\mime_type::get_info_from_filename($filename);
print_r($info);