CGI-UploadEngine

 view release on metacpan or  search on metacpan

Controller/UploadEG.pm  view on Meta::CPAN

package MBC::Controller::UploadEG;
use Moose;
use namespace::autoclean;
use CGI::UploadEngine;
use YAML::Any qw(LoadFile);

# Sets the actions in this controller to be registered with this prefix
__PACKAGE__->config->{namespace} = 'upload';

BEGIN {extends 'Catalyst::Controller'; }

=head1 NAME

MBC::Controller::UploadEG - Catalyst Controller

=head1 DESCRIPTION

Working sample of CGI::UE developer application.

=head1 METHODS

=over 4

=item * form_eg

Uses CGI::UE I<upload_prepare()> to inject AJAX supported file select box.

=item * handler_eg

Uses CGI::UE I<upload_retrieve()> to get info on a successful upload.

=back

=cut
our $config_file = '/var/www/.uploadeg';

sub form_eg : Local {
        my ( $self, $c ) = @_;

	# Get configuration
	my $config = LoadFile($config_file);

	# Create engine
        my $upload = CGI::UploadEngine->new();

	# Prepare upload 
	$c->stash->{file_upload} = $upload->upload_prepare({ file_path        => $config->{file_path},
							     max_size         => $config->{max_size},
							     min_size         => $config->{min_size},
							     allowed_types    => $config->{allowed_types},
							     disallowed_types => $config->{disallowed_types} });

	# Munge template
	$c->stash->{action_url}  = $c->config->{root_url} . 'upload/handler_eg';
	$c->stash->{template}    = 'upload/form_eg.tt2';
}

sub handler_eg : Local {
        my ( $self, $c ) = @_;

	# Parse form data
	my $token  = $c->request->param('token');
	my $other  = $c->request->param('other');



( run in 1.337 second using v1.01-cache-2.11-cpan-39bf76dae61 )