|
CGI::UploadEasy - Facilitate file uploads |
CGI::UploadEasy - Facilitate file uploads
use CGI::UploadEasy;
my $ue = CGI::UploadEasy->new(-uploaddir => '/path/to/upload/directory');
my $cgi = $ue->cgiobject;
my $info = $ue->fileinfo;
CGI::UploadEasy is a wrapper around, and relies heavily on, CGI.pm. Its
purpose is to provide a simple interface to the upload functionality of CGI.pm.
At creation of the CGI::UploadEasy object, the module saves one or more files
from a file upload request in the upload directory, and information about uploaded
files is made available via the fileinfo() method. CGI::UploadEasy performs
a number of tests, which limit the risk that you encounter difficulties when
developing a file upload application.
CGI object that CGI::UploadEasy uses internally,
which gives access to all the CGI.pm methods.
If you prefer the function-oriented style, you can import a set of methods instead. Example:
use CGI qw/:standard/;
print header;
This script handles a file upload request by saving a number of files in the upload directory and printing the related info:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI::UploadEasy;
use Data::Dumper;
my $ue = CGI::UploadEasy->new(-uploaddir => '/path/to/upload/directory');
my $info = $ue->fileinfo;
my $cgi = $ue->cgiobject;
print $cgi->header('text/plain');
print Dumper $info;
Since CGI::UploadEasy is meant for file uploads, it requires that the request
data is multipart/form-data encoded. An application/x-www-form-urlencoded
POST request will cause a fatal error.
No CGI object may be created before the CGI::UploadEasy object has been
created, or else the upload will fail. Likewise, if you import method names from
CGI.pm, be careful not to call any CGI functions before the creation of the
CGI::UploadEasy object.
Copyright © 2005 Gunnar Hjalmarsson http://www.gunnar.cc/cgi-bin/contact.pl
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
CGI::UploadEasy - Facilitate file uploads |