#!/usr/bin/perl -w use CGI::Carp "fatalsToBrowser"; use CGI qw(:all); use warnings; use DBI; use lib './module'; use HTML::Template; use FindBin; use File::Type::WebImages 'mime_type'; use strict; use vars qw($action $redirect $root_path $prog_lib %lang); &get_path; $action = param('action'); my $cgi = CGI->new(); my %params = $cgi->Vars(); #my $path = $root_path . '/yambe/bilder/userpic'; my $path = 'd:/Projekte/YAMBE/Development/2.x/yambe/bilder/userpic'; my $filehandle = $cgi->upload('user_pic'); my $filename = $params{'user_pic'}; #$filename = (split(/[\\\/]/,$filename))[-1]; #$filename =~ s/[^A-Za-z0-9_\.\-]//g; #$filename =~ s/\\/\//g; my %Mode = ( '' => \&form, 'upload' => \&upload_datei, ); if($Mode{$action}) { $Mode{$action}->(); } else { $redirect = $root_path . "/cgi-bin/yambe/register.cgi"; my $q = new CGI; print $q->redirect($redirect); }; sub form { my $template = HTML::Template->new(filename => 'upload.tmpl', path => ["$prog_lib/templates/standard"]); #Bindet den Header ein. &header(0); $template->param(ROOT_PATH => $root_path); print $template->output; #Bindet den Footer ein. &footer(0); exit; } sub upload_datei { #Bindet den Header ein. &header(0); upload_file($filename,$filehandle,$path); my $uploaded_file = $path . "\\" . $filename; my $check_file = mime_type($uploaded_file); if ($check_file eq undef) { ... } else { ... } #Bindet den Footer ein. &footer(0); exit; } sub upload_file { my ($filename,$filehandle,$path) = @_; my $target = $path.'/'.$filename; if(-e $target){ print "Zieldatei existiert schon!"; exit(0); } else{ binmode $filehandle; open(TARGET,">$target") or die $!; binmode TARGET; my ($buffer); while(read $filehandle,$buffer,1024){ print TARGET $buffer; } close TARGET; print "