Hmm, how did my message end up on both lists, I meant to just send it to the
CGI list? Sorry for the extra noise. But now that it's started, I'll reply
to both in case people are following it.

The name of my upload file isn't literally file, it is contained in the
variable named file. I agree that the upload method is probably my problem;
someone else said it was just buggy. :(

The other method without using the upload method in the book is param($file)
as the filehandle, but it alludes to conflicts with strict that way. There
is an example of that at "The Official Guide to Programming with CGI.pm"
website, so I think I'll try that next.

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Lynn Glessner" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, August 21, 2001 9:49 AM
Subject: Re: Upload script


> I dont use CGI.pm a whole lot but looking at the perldocs for CGI.pm it
> mentions that upload method takes the name of the upload field.  Looking
at
> the example in the POD it appears that you should be calling upload like
this
>
> my $fh = $q->upload( 'file' );
>
> instead of
>
> my $fh = $q->upload( $file );
>
> checkout perldoc CGI ..
>
> On Tue, Aug 21, 2001 at 08:49:32AM -0700, Lynn Glessner shaped the
electrons to read:
> > I have copied a script out of "CGI programming with perl", to see if I
> > understand how uploading a file would work. So far it doesn't - the code
> > checks correctly with perl -c but then I get an internal server error
500. I
> > think I found a minor error in the book example already :( Can anyone
help?
> > I have apache and perl 5.6.0.
> >
> > The apache error log has:
> > Can't use an undefined value as a symbol reference at ... line 43
> > Premature end of script headers
> >
> > I downloaded the latest CGI module I could find, since there was a note
that
> > upload was added to CGI 2.47 perllocal.pod shows CGI 2.7.1, but maybe
there
> > is some kind of restart I need to do? I didn't know how to check what
> > version I had *before* I updated, so this may be a red herring.
> >
> > Here are the relevanet bits of code:
> >
> > use strict;
> > use CGI;
> > use Fcntl qw( :DEFAULT :flock );
> >
> > use constant UPLOAD_DIR => "/usr/local/apache/data/uploads";
> > use constant BUFFER_SIZE => 16_384;
> > use constant MAX_FILE_SIZE => 1_048_576; # Limit each upload to 1 MB
> > use constant MAX_OPEN_TRIES => 100;
> > use constant MAX_DIR_SIZE => 175 * MAX_FILE_SIZE;
> >
> > $CGI::DISABLE_UPLOADS = 0;
> > $CGI::POST_MAX = MAX_FILE_SIZE;
> >
> > my $q = new CGI;
> > $q->cgi_error and error( $q, "Error transferring 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 = "";
> >
> > [snipped, next line is line 43]
> >
> > binmode $fh;
> > binmode OUTPUT;
> >
> > # Write contents to output file
> > while (read ($fh, $buffer, BUFFER_SIZE) ) {
> >     print OUTPUT $buffer;
> > }
> >
> > close OUTPUT;
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to