Koha::Uploader - Facilitate file uploads (temporary and permanent)
use Koha::Uploader; use Koha::UploadedFile; use Koha::UploadedFiles; # add an upload (see tools/upload-file.pl) # the public flag allows retrieval via OPAC my $upload = Koha::Uploader->new( public => 1, category => 'A' ); my $cgi = $upload->cgi; # Do something with $upload->count, $upload->result or $upload->err # get some upload records (in staff) via Koha::UploadedFiles my $uploads1 = Koha::UploadedFiles->search({ filename => $name }); my $uploads2 = Koha::UploadedFiles->search_term({ term => $term }); # staff download (via Koha::UploadedFile[s]) my $rec = Koha::UploadedFiles->find( $id ); my $fh = $rec->file_handle; print Encode::encode_utf8( $input->header( $rec->httpheaders ) ); while( <$fh> ) { print $_; } $fh->close;
This module is a refactored version of C4::UploadedFile but adds on top of that the new functions from report 6874 (Upload plugin in editor). That report added module UploadedFiles.pm. This module contains the functionality of both. The module has been revised to use Koha::Object[s]; the delete method has been moved to Koha::UploadedFile[s], as well as the get method.
Returns new object based on Class::Accessor. Use tmp or temp flag for temporary storage. Use public flag to mark uploads as available in OPAC. The category parameter is only useful for permanent storage.
Returns CGI object. The CGI hook is used to store the uploaded files.
Returns number of uploaded files without errors
Returns a string of id's for each successful upload separated by commas.
Returns hashref with errors in format { file => { code => err }, ... } Undefined if there are no errors.
allows_add_by checks if $userid has permission to add uploaded files
Koha Development Team Larger parts from Galen Charlton, Julian Maurice and Marcel de Rooy