OpenPlugin::Upload - Handle file uploads


OpenPlugin documentation Contained in the OpenPlugin distribution.

Index


Code Index:

NAME

Top

OpenPlugin::Upload - Handle file uploads

SYNOPSIS

Top

 my $OP = OpenPlugin->new();

 my @uploads = $OP->upload->get_incoming()

 my $upload = $OP->upload->get_incoming( $name );

METHODS

Top

get_incoming( [ $name ] )

get( [ $name ] )

With no arguments, this returns a list of filenames mapping to the files uploaded by the client. If you pass in $name then you get a hashref containing the keys:

* name

The name given in the upload field.

* type

The content-type of the file.

* size

The size of the file.

* filehandle

The file handle of the file.

* filename

The real name of the file being uploaded.

set_incoming( \%upload )

Associates the OpenPlugin::Upload %upload hash with $upload-{ name }>.

See get_incoming for a list of valid parameters this function accepts.

TO DO

Top

See the TO DO section of the <OpenPlugin::Request> plugin.

BUGS

Top

None known.

SEE ALSO

Top

See the individual driver documentation for settings and parameters specific to that driver.

COPYRIGHT

Top

AUTHORS

Top

Eric Andreychek <eric@openthought.net>


OpenPlugin documentation Contained in the OpenPlugin distribution.

package OpenPlugin::Upload;

# $Id: Upload.pm,v 1.13 2003/04/03 01:51:24 andreychek Exp $

use strict;
use base                    qw( OpenPlugin::Plugin );
use Data::Dumper            qw( Dumper );

$OpenPlugin::Upload::VERSION = sprintf("%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/);

sub OP   { return $_[0]->{_m}{OP} }
sub type { return 'upload' }

*get = \*get_incoming;

sub get_incoming {
    my ( $self, $name ) = @_;
    unless ( $name ) {
        return ( ref $self->state->{upload} eq 'HASH' )
                 ? keys %{ $self->state->{upload} } : ();
    }
    if ( ref $self->state->{upload}{ $name } eq 'ARRAY' and wantarray ) {
        return @{ $self->state->{upload}{ $name } };
    }

    return $self->state->{upload}{ $name };
}

sub set_incoming {
    my ( $self, $upload ) = @_;

    return undef unless ( $upload->{ name } );

    return $self->state->{ upload }{ $upload->{ name } } = $upload;

}


1;

__END__