HTML::...Upload(3pm)

πŸ“¦
version 0.40068 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

🌸 NAME 🌸

okay bestie, meet HTML::FormHandler::Field::Upload β€” it’s the file upload field, and this whole page is HTML::...Upload(3pm) from the User Contributed Perl Documentation corner. πŸ’–

✨ VERSION ✨

version 0.40068 β€” that’s the version, no cap. ✨

πŸ’… DESCRIPTION πŸ’…

This field is designed to be used with a blessed object with a 'size' method β€” think Catalyst::Request::Upload β€” or a filehandle. It validates that the file is not empty and is within the 'min_size' and 'max_size' limits. Those limits are in bytes, bestie. πŸ”₯

🚨 important vibe check: a form containing this field must have the enctype set. Periodt.

Here’s the example setup, exactly:

           package My::Form::Upload;
           use HTML::FormHandler::Moose;
           extends 'HTML::FormHandler';

           has '+enctype' => ( default => 'multipart/form-data');

           has_field 'file' => ( type => 'Upload', max_size => '2000000' );
           has_field 'submit' => ( type => 'Submit', value => 'Upload' );

Then in your controller:

           my $form = My::Form::Upload->new;
           my @params = ( file => $c->req->upload('file') )
                    if $c->req->method eq 'POST';
           $form->process( params => { @params } );
           return unless ( $form->validated );

Also β€” and this is lowkey useful β€” you can set the min_size and max_size limits to undef if you don’t want them to be validated. 🫢

πŸ¦‹ DEPENDENCIES πŸ¦‹

🧚 widget 🧚

Widget type is 'upload'. That’s the dependency tea. πŸ“

πŸ‘‘ AUTHOR πŸ‘‘

FormHandler Contributors - see HTML::FormHandler. πŸ‘‘

This software is copyright (c) 2017 by Gerda Shank.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay, that’s the manual page, bestie πŸ’– β€” signing off from perl v5.34.0, dated 2022-03-25, with HTML::...Upload(3pm) energy. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from