line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Constraint::File; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
814
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
14
|
|
7
|
|
|
|
|
|
|
extends 'HTML::FormFu::Constraint'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8652
|
use Scalar::Util qw( blessed ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
250
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub constrain_value { |
12
|
4
|
|
|
4
|
0
|
3
|
my ( $self, $value ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
4
|
100
|
66
|
|
|
16
|
return 1 if !defined $value || $value eq ''; |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
66
|
|
|
19
|
return blessed($value) && $value->isa('HTML::FormFu::Upload'); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
HTML::FormFu::Constraint::File - File Upload Constraint |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 VERSION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
version 2.05 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Ensure the submitted value is a file upload. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This Constraint is not needed if you use any of the C<File::*> Constraints, |
38
|
|
|
|
|
|
|
as they all make the same check as this Constraint does. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 LIMITATIONS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This can only verify that your CGI backend (CGI, Catalyst, CGI::Simple) |
43
|
|
|
|
|
|
|
thinks it was a file upload. If the user submits a filename which doesn't |
44
|
|
|
|
|
|
|
exist on their system, you will probably get a valid L<HTML::FormFu::Upload> |
45
|
|
|
|
|
|
|
object, with a valid filehandle, but no Content-Length. This Constraint |
46
|
|
|
|
|
|
|
would still see this as a valid uploaded file - if you want to ensure that |
47
|
|
|
|
|
|
|
you get a file with content, instead use |
48
|
|
|
|
|
|
|
L<HTML::FormFu::Constraint::File::Size> with |
49
|
|
|
|
|
|
|
L<min|HTML::FormFu::Constraint::File::Size/min> set to C<1>. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
L<HTML::FormFu> |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 AUTHOR |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 LICENSE |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
64
|
|
|
|
|
|
|
the same terms as Perl itself. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |