A helper for working with MIME types, particularly for validating uploads.

0.1.0 2018-04-22 21:42 UTC

This package is not auto-updated.

Last update: 2020-02-21 18:23:11 UTC


A helper class for working with MIME types. Should be particularly useful for validating file uploads.

Based on the MIME type list found here.


Via Composer

$ composer require imonroe/mime_utils


  $allowed_mimes = new MimeUtils;
  // You can allow all the available types:
  // or you can allow just certain subtypes:
  // text types include htm, html, css
  // The application types allow potentially problematic types, e.g., pdf, swf, js, class
  // enable it only if necessary.
  // You can get the allowed extenstions as a string:
  $mime_string = 'mimes:' . $allowed_mimes->get_extensions('string');
  // or as an array: 
  $mime_string = 'mimes:' . $allowed_mimes->get_extensions('array');
  // or as JSON:
  $mime_string = 'mimes:' . $allowed_mimes->get_extensions('json');

  // You can also get the types in the same way, in the same formats:
  $mime_string = 'mimes:' . $allowed_mimes->get_types('string');
  // or 
  $mime_string = 'mimes:' . $allowed_mimes->get_types('array');
  // or 
  $mime_string = 'mimes:' . $allowed_mimes->get_types('json');

Change log

Please see CHANGELOG for more information on what has changed recently.


$ composer test


Please see CONTRIBUTING and CODE_OF_CONDUCT for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.