#!/usr/bin/perl -w
use strict;
my $basedir = "/var/www/upload";
use CGI;
my $q = new CGI;
my $fh = $q->upload("test");
checkdir();
my $file = $fh;
$file =~ s!^.*(\\|\/)!!;
open (OUTFILE,">>","$basedir/$file") || die "error $! \n";
while (<$fh>) {
print OUTFILE $_;
}
print "Content-type: text/html\n";
sub checkdir () {
opendir (DIR ,$basedir) or die "error $!\n";
my @d = readdir(DIR);
closedir(DIR);
foreach my $key (@d){
if ($file eq $key) {
print "Content-type: text/html\n\n";
print "<h2>file with such name already exists in the dir</h2>\n";
exit(0);
}
}
}
немогу понять в чем проблема .
вот что выводит
./up3.cgi
main::checkdir() called too early to check prototype at ./up3.cgi line 7.
...
..