Mein fertiges Script (falls es jemanden interessiert):
#!/usr/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Storable qw(store retrieve);
my $cgi = new CGI;
#################
### Variables ###
#################
my $dir = '/srv/ftp/Upload/';
my $www = 'ftp://where-ever.tld/Upload/';
my $password = 'paschwordd';
#########################
### Print File-Header ###
#########################
print $cgi->header; # "Content-Type: text/html; charset=ISO-8859-1\n\n"
##############################
### Brute Force protection ###
##############################
my $lastaccessref;
eval { $lastaccessref = retrieve($dir.'upload.lastaccess') };
if($lastaccessref->{'IP'} eq $ENV{REMOTE_ADDR} && time - $lastaccessref->{'Time'} <= 5 ) {
my %lastaccess = ('IP' => $ENV{REMOTE_ADDR}, 'Time' => time);
eval { store(\%lastaccess, $dir.'upload.lastaccess') };
die('Brute Force protection');
} else {
my %lastaccess = ('IP' => $ENV{REMOTE_ADDR}, 'Time' => time);
eval { store(\%lastaccess, $dir.'upload.lastaccess') };
}
######################
### Password check ###
######################
if($cgi->param("password") ne $password) {
print <<"HTML";
<html>
<head>
<title>Datei-Upload</title>
</head>
<body bgcolor="#FFFFFF">
<h1>Zugriff verweigert!</h1>
</body>
</html>
HTML
die("Access denied");
}
############################
### Get File-Information ###
############################
my $file = $cgi->param("file");
############################
### Force legal filename ###
############################
$file =~ s/ä/ae/gi;
$file =~ s/ö/oe/gi;
$file =~ s/ü/ue/gi;
$file =~ s/ß/ss/gi;
#$file =~ s/\W/_/gi;
$file =~ s/[^ a-z 0-9 \- . ]/_/gi;
####################################
### Open file system for writing ###
####################################
my $fname = $file;
my $finfo = $ENV{REMOTE_ADDR}.'_'.time;
$finfo =~ s/\./\-/gi;
$fname =~ s#(.+)\.(\w+)#$1.$finfo.$2#;
if( $fname !~ m/\./gi )
{ $fname = $file.'.'.$finfo; }
my $store = $dir.$fname;
open DAT,'>'.$store or die 'Error processing file: ',$!;
#############################
### Switch to binary mode ###
#############################
binmode $file;
binmode DAT;
##########################
### Get and write file ###
##########################
my $data;
while(read $file,$data,1024) {
print DAT $data;
}
close DAT;
###################
### Text output ###
###################
my $dl = $www.$fname;
print <<"HTML";
<html>
<head>
<title>Datei-Upload</title>
</head>
<body bgcolor="#FFFFFF">
<h1>Die Datei $file wurde erfolgreich hochgeladen.</h1>
<p>Gespeichert unter: <a href=\"$dl\">$dl</a></p>
</body>
</html>
HTML
Die Variablen für die directories und passwörter müssen natürlich noch angepasst werden ...