1use strict; 2 3package HTML::FormFu::QueryType::CGI::Simple; 4$HTML::FormFu::QueryType::CGI::Simple::VERSION = '2.07'; 5# ABSTRACT: uploaded file 6 7use Moose; 8 9extends 'HTML::FormFu::QueryType::CGI'; 10 11sub parse_uploads { 12 my ( $class, $form, $name ) = @_; 13 14 my $query = $form->query; 15 my @params = $query->param($name); 16 my @new; 17 18 for my $param (@params) { 19 if ( my $file = $query->upload($param) ) { 20 my $filename = $param; 21 22 $param = $class->new( 23 { _param => $file, 24 filename => $filename, 25 parent => $form, 26 } ); 27 28 my $headers = HTTP::Headers->new( 29 'Content-Type' => $query->upload_info( $filename, 'mime' ), 30 'Content-Length' => $query->upload_info( $filename, 'size' ), 31 ); 32 33 $param->headers($headers); 34 $param->size( $headers->content_length ); 35 $param->type( $headers->content_type ); 36 } 37 push @new, $param; 38 } 39 40 return if !@new; 41 42 return @new == 1 ? $new[0] : \@new; 43} 44 45sub fh { 46 my ($self) = @_; 47 48 return $self->form->query->upload( $self->filename ); 49} 50 51__PACKAGE__->meta->make_immutable; 52 531; 54 55__END__ 56 57=pod 58 59=encoding UTF-8 60 61=head1 NAME 62 63HTML::FormFu::QueryType::CGI::Simple - uploaded file 64 65=head1 VERSION 66 67version 2.07 68 69=head1 METHODS 70 71=head2 headers 72 73Inherited, see L<HTML::FormFu::QueryType::CGI/headers> for details. 74 75=head2 filename 76 77Inherited, see L<HTML::FormFu::QueryType::CGI/filename> for details. 78 79=head2 fh 80 81Returns a read-only filehandle. 82 83=head2 slurp 84 85Inherited, see L<HTML::FormFu::QueryType::CGI/slurp> for details. 86 87=head2 size 88 89Inherited, see L<HTML::FormFu::QueryType::CGI/size> for details. 90 91=head2 type 92 93Inherited, see L<HTML::FormFu::QueryType::CGI/type> for details. 94 95=head1 SEE ALSO 96 97Is a sub-class of, and inherits methods from 98L<HTML::FormFu::QueryType::CGI>, L<HTML::FormFu::Upload> 99 100L<HTML::FormFu>, L<HTML::FormFu::Element::File> 101 102=head1 AUTHOR 103 104Carl Franks, C<cfranks@cpan.org> 105 106=head1 LICENSE 107 108This library is free software, you can redistribute it and/or modify it under 109the same terms as Perl itself. 110 111=head1 AUTHOR 112 113Carl Franks <cpan@fireartist.com> 114 115=head1 COPYRIGHT AND LICENSE 116 117This software is copyright (c) 2018 by Carl Franks. 118 119This is free software; you can redistribute it and/or modify it under 120the same terms as the Perl 5 programming language system itself. 121 122=cut 123