package Cookbook::PrintUploads; use Apache::Constants qw(OK); use Apache::Request; use Apache::Util qw(escape_html); use strict; sub handler { # Standard stuff, with added options... my $r = Apache::Request->new(shift, POST_MAX => 10 * 1024 * 1024, # in bytes, so 10M DISABLE_UPLOADS => 0); my $status = $r->parse(); # Return an error if we have problems. return $status unless $status == OK; $r->send_http_header('text/html'); $r->print("\n"); $r->print("

Upload files

"); # Iterate through each uploaded file. foreach my $upload ($r->upload) { my $filename = $upload->filename; my $filehandle = $upload->fh; my $size = $upload->size; $r->print("You sent me a file named $filename, $size bytes
"); $r->print("The first line of the file is:
"); my $line = <$filehandle>; $r->print(escape_html($line), "
"); } $r->print("Done......
"); # Output a simple form. $r->print(< File 1
File 2
File 3

EOF return OK; }; 1;