line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::QueryType::CGI; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
521
|
use strict; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
398
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
32
|
use Moose; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
55
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Upload'; |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
42524
|
use HTTP::Headers; |
|
9
|
|
|
|
|
50628
|
|
|
9
|
|
|
|
|
289
|
|
11
|
9
|
|
|
9
|
|
55
|
use Scalar::Util qw( blessed ); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
1933
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub parse_uploads { |
14
|
21
|
|
|
21
|
0
|
29
|
my ( $class, $form, $name ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
21
|
|
|
|
|
445
|
my $query = $form->query; |
17
|
|
|
|
|
|
|
## CGI wants you to use $query->multi_param($foo). |
18
|
|
|
|
|
|
|
## doing so breaks CGI::Simple. So shoosh it up for now. |
19
|
21
|
|
|
|
|
34
|
local $CGI::LIST_CONTEXT_WARN = 0; |
20
|
|
|
|
|
|
|
|
21
|
21
|
|
|
|
|
78
|
my @params = $query->param($name); |
22
|
21
|
|
|
|
|
372
|
my @new; |
23
|
|
|
|
|
|
|
|
24
|
21
|
|
|
|
|
35
|
for my $param (@params) { |
25
|
26
|
100
|
|
|
|
828
|
if ( blessed $param ) { |
26
|
18
|
|
|
|
|
24
|
my $filename = $param; |
27
|
|
|
|
|
|
|
|
28
|
18
|
|
|
|
|
738
|
$param = $class->new( { |
29
|
|
|
|
|
|
|
_param => $param, |
30
|
|
|
|
|
|
|
filename => sprintf( "%s", $filename ), |
31
|
|
|
|
|
|
|
parent => $form, |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# TODO: for now, parent points to the form |
34
|
|
|
|
|
|
|
# pointing to a field will require handling multiple |
35
|
|
|
|
|
|
|
# fields of the same name |
36
|
|
|
|
|
|
|
# if fixed, other QueryTypes and MultiForm will need updating |
37
|
|
|
|
|
|
|
} ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $headers |
40
|
18
|
|
|
|
|
30
|
= HTTP::Headers->new( %{ $query->uploadInfo($filename) } ); |
|
18
|
|
|
|
|
63
|
|
41
|
|
|
|
|
|
|
|
42
|
18
|
|
|
|
|
2264
|
$param->headers($headers); |
43
|
18
|
|
|
|
|
49
|
$param->size( $headers->content_length ); |
44
|
18
|
|
|
|
|
52
|
$param->type( $headers->content_type ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
26
|
|
|
|
|
54
|
push @new, $param; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
21
|
50
|
|
|
|
42
|
return if !@new; |
51
|
|
|
|
|
|
|
|
52
|
21
|
100
|
|
|
|
87
|
return @new == 1 ? $new[0] : \@new; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub fh { |
56
|
5
|
|
|
5
|
1
|
6
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
12
|
return $self->_param; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
HTML::FormFu::QueryType::CGI - uploaded file |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 2.05 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 headers |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
As of L<HTML::FormFu> version C<0.02004>, returns a L<HTTP::Headers> object. |
80
|
|
|
|
|
|
|
- Previously returned a hashref of values. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 filename |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns the browser-submitted filename of the local file. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 fh |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a read-only filehandle. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 slurp |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the contents of the uploaded file. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 size |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
A shortcut for C<< $upload->headers->content_length >>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns the size of the uploaded file in bytes. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 type |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
A shortcut for C<< $upload->headers->content_type >>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns the browser-submitted Content-Type of the uploaded file. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from |
109
|
|
|
|
|
|
|
L<HTML::FormFu::Upload> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<HTML::FormFu>, L<HTML::FormFu::Element::File> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as Perl itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |