#*****************************************************************#
  # ALLGEMEIN:                                                      #
  # Dateiupload                                                     #
  #*****************************************************************#
  

  ########## HTML-Bereich ##########

  # Multipart-Definition im Form-Tag

  <form enctype="multipart/form-data" method="post" name="wm" action="upload.pl">
  <input type="file" name="UPLOAD">
  <input type="submit" value="save">
  </form>



  ########### Perl-Bereich ##########

  # Modul CGI einbinden

  use CGI;

  # Ablageordner 

  my $PFAD = "/home/www/web0/html/bilder/";

  my @allow = (gif, jpg, jpeg, png);

  my $file = $cgi->param("UPLOAD");
  my $data;

  my $filepfad = $file;

  # Pfadübergabe abhängig von cgi-version
  if($filepfad =~ m/\\/) {
    # Dateiname vom Pfad abtrennen
    $filepfad =~ s/\\/\//g;
    $filepfad =~ m/.*[\/\\](.+)/g;
    # Spalte DATEINAME und EXTENSION
    @ext = (split(/\./, $1));
  } else {
    @ext = (split(/\./, $file));
  }
  # Erlaubte Dateiformate prüfen

  if (grep {$_ =~ /$ext[1]/i} @allow) {

  open FILE, ('>'.$PATH.'/'.$ext[0].'.'.$ext[1]);
  binmode $file;
  binmode FILE;
  while (read $file, $data, 1024) { print FILE $data; }
  close FILE;

 }