CGI-FileUpload
view release on metacpan or search on metacpan
lib/CGI/FileUpload.pm view on Meta::CPAN
=head2 Actions
=head3 $fupload->upload() (query=>$cgi_query [,opts])
Start the upload. A CGI::query must be passed. Other optional arguments can be of
=over 4
=item asynchronous=>(1|0) to see if the transfer must be completed before returning (0 value). default is 1;
=back
=head3 $fupload->remove()
Removes the file upload structure from the temp directory
=head3 $fupload->kill([signal=>value])
Kill the uploading process (default signal is 'INT')
lib/CGI/FileUpload.pm view on Meta::CPAN
<input type='hidden' name='action' value='upload'/>
</table>
</form>
EOT
}
sub upload{
my $self=shift;
my %params=@_;
my $query=$params{query} or Carp::confess("no query was passed");
my $asynchronous=(exists $params{asynchronous})?$params{asynchronous}:1;
my $filename=$query->param('uploadfile');
$self->file_orig($filename);
$self->pid($$);
$self->from_ipaddr($ENV{REMOTE_ADDR});
#upload
my $localfile=$self->file();
lib/CGI/FileUpload.pm view on Meta::CPAN
my $id=idcookie(query=>$query);
my $cookie=CGI::cookie(-name=>'cgi-fileupload-id',
-value=>$id,
-expires=>'+100d'
);
$self->from_id($id->{id});
print $query->header(-type=>'text/plain',
-cookie=>$cookie,
-length=>(length($ret))+ $asynchronous?0:1,
);
print $ret;
$self->upload_status('loading');
my $fhin=CGI::upload('uploadfile')||CORE::die "cannot convert [$filename] into filehandle: $!";
my $l=0;
while(<$fhin>){
$l+=length($_);
print FHOUT $_;
}
( run in 0.539 second using v1.01-cache-2.11-cpan-0d8aa00de5b )