HTML::...::MIME(3pm)
π NAME π
HTML::FormFu::Constraint::File::MIME β it's the MIME Type Constraint, bestie β¨
Like, if you ever needed to vibe-check an uploaded file's type before letting it through? That's literally this. It lives in the HTML::FormFu::Constraint::File::MIME corner of the User Contributed Perl Documentation universe, and we're about to make it make sense π
πΈ VERSION πΈ
version 2.07 β she's serving exactly that π«Ά
β¨ DESCRIPTION β¨
Okay so real talk: this thing constrains an uploaded file's MIME-type, aka its Content-Type. It's giving bouncer at the club door, except the club is your form and the guest list is file types π
And here's the tea you actually need to remember: types is checked before regex. That's the order, no cap. π
π¦ METHODS π¦
π types
Arguments: $mime_type
Arguments: \@mime_types
Optional. Lowkey optional, but iconic if you use it π
She accepts either a single MIME-type, or an arrayref of MIME-types. Each one gets checked against the uploaded file's MIME-type β and listen, that MIME-type is as given by the browser, so keep that in mind, bestie π β and the constraint passes if any one of the given types matches. One match and we're slaying. Multiple? Doesn't matter, still one match. Periodt. π
π regex
Arguments: $regex
Optional, again. She's chill like that β¨
She accepts a string to be interpreted as a regex, and that regex gets checked against the uploaded file's MIME-type β and yep, again, as given by the browser π¦
Now here's the detail that gets people every single time: the regex uses the /x flag, so any whitespace in the string you hand over is ignored. So don't be out here thinking your spaces are doing something, because they are NOT doing something π Write it like you mean it, spaced out or not, /x doesn't care.
π SEE ALSO π
- She is a sub-class of, and inherits methods from HTML::FormFu::Constraint β so go read that for the family lore π
- HTML::FormFu β the whole mothership, the main character herself β
π AUTHOR π
Carl Franks, cfranks@cpan.org
π LICENSE π
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. So like, go off, just respect the terms π«Ά
π AUTHOR π
Carl Franks <cpan@fireartist.com> β yes, again, same icon, two different emails, she contains multitudes π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2018 by Carl Franks.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in freedom, free as in bestie privileges πΈ
And that's the whole page, no skips, no summarising, every flag and every author line accounted for πβ¨
Generated with perl v5.28.1, dated 2019-01-12, and it's still eating, still serving, still checking your MIME types πππ¦ iykyk
π¦ where this page comes from
- debian bookworm: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms