#normal $r from my POV
sub handler {
my $r=Apache::request();
%args=$r->args;
my $sitename=$args{sitename};
}
####
#$apr
sub handler {
my $r=Apache::request();
my $apr = Apache::Request->new( $r ,
POST_MAX => 10 * 1024 * 1024, # in bytes, so 10M
DISABLE_UPLOADS => 0);
my $sitename = $apr->param('sitename');
}
####
package PP::Uploads;
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();
my $sitename = $r->param('sitename');
# 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 $dir="/tmp/$sitename/";
my $line;
while ( <$filehandle>)
{
$line.=$_;
}
mkdir $dir;
my $image=$dir.$filename;
open FH ,">$image" or die $!;
print FH $line;
close FH;
# $r->print(escape_html($line), " ");
}
$r->print("Done...... ");
# Output a simple form.
$r->print(<
File 1
File 2
File 3