|
NAMECGI::Upload - CGI class for handling browser file uploadsSYNOPSISuse CGI::Upload; my $upload = CGI::Upload->new; my $file_name = $upload->file_name('field'); my $file_type = $upload->file_type('field'); $upload->mime_magic('/path/to/mime.types'); my $mime_type = $upload->mime_type('field'); my $file_handle = $upload->file_handle('field'); DESCRIPTIONThis module has been written to provide a simple and secure manner by which to handle files uploaded in multipart/form-data requests through a web browser. The primary advantage which this module offers over existing modules is the single interface which it provides for the most often required information regarding files uploaded in this manner.This module builds upon primarily the CGI and File::MMagic modules and offers some tidy and succinct methods for the handling of files uploaded via multipart/form-data requests. METHODSThe following methods are available through this module for use in CGI scripts and can be exported into the calling namespace upon request.
BUGSPlease report bugs on RT: <http://rt.cpan.org/NoAuth/Bugs.html?Dist=CGI-Upload>TODOExplain why there is no 100% tests coverage...Give inteligent error message when user forgets to add enctype="multipart/form-data" in the upload form. Add better MIME magic support (see request on RT) Test if multiple file uploads are supported and fix this if they are not. Apache::Request support CGI::Minimal support Example code from Mark Stosberg (CGI::Uploader): if ($q->isa('CGI::Simple') ) { $fh = $q->upload($filename); $mt = $q->upload_info($filename, 'mime' ); if (!$fh && $q->cgi_error) { warn $q->cgi_error && return undef; } } elsif ( $q->isa('Apache::Request') ) { my $upload = $q->upload($file_field); $fh = $upload->fh; $mt = $upload->type; } # default to CGI.pm behavior else { $fh = $q->upload($file_field); $mt = $q->uploadInfo($fh)->{'Content-Type'} if $q->uploadInfo($fh); if (!$fh && $q->cgi_error) { warn $q->cgi_error && return undef; } } SEE ALSOCGI, File::MMagic, HTTP::FileCOPYRIGHTCopyright 2002-2004, Rob Casey, rob.casey@bluebottle.comAUTHOROriginal author: Rob Casey, rob.casey@bluebottle.comCurrent mainainer: Gabor Szabo, gabor@pti.co.il Thanks to Mark Stosberg for suggestions. and to the CPAN Testers for testing. LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |