Hi could someone tell me what's wrong with this cgi please
Every time I try to run the next script througha form I get a 500
Internal Server Error and my http log(apache) gives me this error:
[Wed Apr 17 04:08:27 2002] [error] [client 217.129.197.231] script not found
or unable to stat: /home/formprof/public_html/cgi-bin/manage.pl
here's the script:
#!/usr/bin/perl -w
use strict;
use CGI;
use Fcntl qw( :DEFAULT :flock);
use constant UPLOAD_DIR => "/home/formprof/public_html/cgi-bin/uploads";
use constant BUFFER_SIZE => 16_384;
use constant MAX_FILE_SIZE => 24_288; #Limit each upload to 1mb
use constant MAX_DIR_SIZE => 100 * 524_288; #Limit total uploads to
100mb
use constant MAX_OPEN_TRIES => 100;
$CGI::DISABLE_UPLOADS = 0;
$CGI::POST_MAX = MAX_FILE_SIZE;
my $q = new CGI;
$q->cgi_error and error( $q, "Error tranfering file: " . $q->cgi_error);
my $file = $q->param( "file" ) || error( $q, "No file received.");
my $filename = $q->param( "filename" ) || error( $q, "No filename
entered" );
my $fh = $q->upload( $file );
my $buffer = "";
if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH} > MAX_DIR_SIZE ) {
error( $q, "Upload directory is full." );
}
#Allow letters, digits, periods, underscores, dashes
#Convert anything else to an underscore
$filename =~ s/[^\w.-]/_/g;
if ( $filename =~/^(\w[\w.-]*)/ ) {
$filename = $1;
}
else {
error( $q, "Invalid file name; files must start with a letter or
number.");
}
#Open output file, making sure the name is unique
until ( sysopen OUTPUT, UPLOAD_DIR . $filename, O_CREAT | O_EXCL ) {
$filename =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e;
$1 >= MAX_OPEN_TRIES and error( $q, "Unable to save your file." );
}
#This is necessary for non-Unix systems; does nothing on Unix
binmode $fh;
binmode OUTPUT;
#Write contents to output file
while ( read( $fh, $buffer, BUFFER_SIZE ) ) {
print OUTPUT $buffer;
}
close OUTPUT;
sub dir_size {
my $dir = shift;
my $dir_size = 0;
#Loop trough files and sum the sizes; doesn't descend down suddirs
opendir DIR, $dir or die "Unable to open $dir: $!";
while ( readdir DIR ) {
$dir_size += -s "$dir/$_";
}
return $dir_size;
}
sub_error {
my( $q, $reason ) = @_;
print $q->header( "text/html" ),
$q->start_html( "Error" ),
$q->h1( "Error" ),
$q->p( "Your upload was not processed because the following
error accured: "),
$q->p( $q->i( $reason ) ),
$q->end_html;
exit;
}
Thanks
Pedro Santos
_________________________________
ArteVirtual, Explora��o de Tecnologias de
Informa��o e Comunica��o
Pedro Costa & Santos,Lda.
Rua Barro Branco, Bustelo
Apartado 256
3720 Oliveira de Azem�is
Tel. (351)256602395 - (351)962836722
www.artevirtual.pt
[EMAIL PROTECTED]
_________________________________
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]