#!/usr/local/bin/perl -wT
use strict;
use CGI ':standard';

print "Content-type: text/html\n\n";

my $soubor = param ('nahrat');
my $info = uploadInfo ($file);
my $typ = $info -> {'Content-Type'};

if ($soubor) {
	open (UPLOAD, ">../../../tmp/uploadfile") || Error ();
	
	my ($data, $delka, $kus);
	while ($chunk = read ($soubor, $data, 1024)) {
		print UPLOAD $data;
		$delka += $kus;
		if ($delka > 51200) {
			print "Tento soubor je pli velk. Limit je 50 KB.";
			exit;
			}
		}
	close (UPLOAD);	
	
	print "<p>Nahrli jste <b>$soubor</b> s MIME typem <b>$typ</b>.";

} else {
		print "Nevybrali jste dn soubor.";	
}

sub Error {
	print "Nelze otevt doasn soubor: $!";
	exit;
	}</a>