CGI-Application-Plugin-AJAXUpload
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/AJAXUpload.pm view on Meta::CPAN
=head2 _ajax_upload_rm
This private method forms the implementation of the run mode. It requires a
I<file> CGI query parameter that provides the file data. Optionally it also
takes a I<validate> parameter that will make other more paranoid checks.
These checks are only optional because if the system is set up correctly
they should never fail.
It takes the following actions:
=over
=item --
It will get the filename and data associated with the upload and
pass the data through the L<Data::FormValidator> if a profile is
supplied.
=item --
If it fails the L<Data::FormValidator> test a failed message will be passed
back to the caller.
=item --
If the I<validate> parameter is set the setup will check. If there
is a problem a status message will be passed back to the user.
=item --
The data will then be copied to the given file, its path being the
combination of the I<httpdocs_dir> parameter, the
I<upload_subdir> and the generated file name.
=item -
The successful JSON message will be passed back to the client.
=back
=head1 DIAGNOSTICS
Most error messages will be passed back to the client as a JSON
message, though in a sanitised form. One error 'Internal Error' is
fairly generic and so the underlying error message is written to standard
error.
=head1 CONFIGURATION AND ENVIRONMENT
CGI::Application::Plugin::AJAXUpload requires no configuration files or
environment variables. However the client side code, the URL to run mode
dispatching and the general web server setup is not supplied.
=head1 DEPENDENCIES
This is using the C<to_json> method from L<CGI::Application::Plugin::JSON>.
As such that module needs to be exported before this module. Or of course you
could just define your own.
=head1 BUGS AND LIMITATIONS
Please report any bugs or feature requests to
C<bug-cgi-application-plugin-ajaxupload@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
One really odd thing is that the content header of the AJAX reply cannot
be 'application/json' as one would expect. This module sets it to
'text/javascript' which works. There is a very short discussion on the
L<YUI forum|http://yuilibrary.com/forum/viewtopic.php?f=89&t=4743&p=16459&hilit=POST+connection#p16459>.
=head1 AUTHOR
Nicholas Bamber C<< <nicholas@periapt.co.uk> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2010, Nicholas Bamber C<< <nicholas@periapt.co.uk> >>. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
The javascript code in the example draws heavily on the code provided
by AllMyBrain.com.
=head1 DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
( run in 2.760 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )