NAME Catalyst::Plugin::UploadProgress - Realtime file upload information SYNOPSIS use Catalyst; MyApp->setup( qw/Static::Simple Cache::FastMmap UploadProgress/ ); # On the HTML page with the upload form, include the progress # JavaScript and CSS. These are available via a single method # if you are lazy. [% c.upload_progress_javascript %] ... # For better performance, copy these 3 files from the UploadProgress # distribution to your static directory and include them normally. ... # Create the upload form with an onsubmit action that creates # the Ajax progress bar. Note the empty div following the form # where the progress bar will be inserted.
# No special code is required within your application, just handle # the upload as usual. sub upload : Local { my ( $self, $c ) = @_; my $upload = $c->request->uploads->{file}; $upload->copy_to( '/some/path/' . $upload->filename ); } DESCRIPTION This plugin is a simple, transparent method for displaying a progress bar during file uploads. DEMO Please see the example/Upload directory in the distribution for a working example Catalyst application with upload progress. Since Upload Progress requires 2 concurrent connections (one for the upload and one for the Ajax, you will need to use either script/upload_poe.pl (which requires Catalyst::Engine::HTTP::POE >= 0.02) or script/upload_server.pl -f. The -f enables forking for each new request. INTERNAL METHODS You don't need to know about these methods, but they are documented here for developers. upload_progress( $progress_id ) Returns the data structure associated with the given progress ID. Currently the data is a hashref with the total size of the upload and the amount of bytes received so far. { size => 110636659, received => 134983 } upload_progress_output Returns a JSON response containing the upload progress data. upload_progress_javascript Inlines the necessary JavaScript and CSS code into your page. For better performance, you should copy the files into your application as displayed above in the Synopsis. EXTENDED METHODS prepare_body_chunk ( $chunk ) Takes each chunk of incoming upload data and updates the upload progress record with new information. dispatch Watches for the special URI /progress?progress_id= and returns the JSON output from "/upload_progress_output". setup AUTHOR Andy Grundman, THANKS The authors of Apache2::UploadProgress, for the progress.js and progress.css code: Christian Hansen Cees Hek COPYRIGHT This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.