use Catalyst::Exception;
use File::Copy ();
use IO::File ();
+use File::Spec::Unix;
-__PACKAGE__->mk_accessors(qw/filename headers size tempname type/);
+__PACKAGE__->mk_accessors(qw/filename headers size tempname type basename/);
sub new { shift->SUPER::new( ref( $_[0] ) ? $_[0] : {@_} ) }
=head1 SYNOPSIS
+ $upload->basename;
$upload->copy_to;
$upload->fh;
$upload->filename;
__PACKAGE__->config( uploadtmp => '/path/to/tmpdir' );
-It is provided a way to have configurable temporary directory.
-If there is no config uploadtmp, system temprary directory will used.
-
- __PACKAGE__->config( uploadtmp => '/path/to/tmpdir' );
-
See also L<Catalyst>.
=head1 DESCRIPTION
return $content;
}
+sub basename {
+ my $self = shift;
+ unless ( $self->{basename} ) {
+ my $basename = $self->filename;
+ $basename =~ s|\\|/|g;
+ $basename = ( File::Spec::Unix->splitpath($basename) )[2];
+ $basename =~ s|[^\w\.-]+|_|g;
+ $self->{basename} = $basename;
+ }
+
+ return $self->{basename};
+}
+
+=head2 $upload->basename
+
+Returns basename for C<filename>.
+
=head2 $upload->tempname
Returns the path to the temporary file.
=head1 AUTHORS
-Sebastian Riedel, C<sri@cpan.org>
-
-Christian Hansen, C<ch@ngmedia.com>
+Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT