imonroe / mimeutils
MIME类型处理的助手,特别是用于验证上传文件。
0.1.0
2018-04-22 21:42 UTC
Requires
- php: ~5.6|~7.0
- illuminate/support: ~5.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-09-13 06:49:22 UTC
README
MIME类型处理的辅助类。特别适用于验证文件上传。
基于以下MIME类型列表:此处找到的列表。
安装
通过Composer
$ composer require imonroe/mime_utils
用法
$allowed_mimes = new MimeUtils; // You can allow all the available types: $allowed_mimes->allow_all(); // or you can allow just certain subtypes: $allowed_mimes->allow('image'); $allowed_mimes->allow('video'); // text types include htm, html, css $allowed_mimes->allow('text'); $allowed_mimes->allow('audio'); // The application types allow potentially problematic types, e.g., pdf, swf, js, class // enable it only if necessary. $allowed_mimes->allow('application'); $allowed_mimes->allow('ms-office'); $allowed_mimes->allow('open-office'); $allowed_mimes->allow('wordperfect'); $allowed_mimes->allow('iwork'); // 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');
变更日志
有关最近变更的更多信息,请参阅变更日志。
测试
$ composer test
贡献
安全
如果您发现任何安全相关的问题,请通过电子邮件ian@ianmonroe.com联系,而不是使用问题跟踪器。
鸣谢
许可
MIT许可证(MIT)。有关更多信息,请参阅许可文件。