OK, I will just post the differences from the example in "CGI Programming
with Perl" (rat book), if anyone wants a copy of my entire script, let me
know. The example script I was using is Example 5-2. upload.cgi on pages
99-101 in the second edition.
1. Upload method
my $fh = $q->upload($file);
should be
my $fh = $q->upload("file");
2. Output file
until (sysopen OUTPUT,UPLOAD_DIR . $filename, O_CREAT | O_EXCL) {
should be
until (sysopen (OUTFILE, UPLOAD_DIR . '/' . $filename, O_WRONLY | O_CREAT |
O_EXCL)) {
3. Headers
I had to add some html-style output that the file uploaded successfully, to
resolve the "premature end of script headers". So after the close output
line I put:
print $q->header,$q->start_html('Results'),"The file has been uploaded",
$q->end_html;
----- Original Message -----
From: "Lynn Glessner" <[EMAIL PROTECTED]>
To: "Bradley M. Handy" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, August 21, 2001 1:13 PM
Subject: Re: Upload script
> {Lights going off - bells - red lights}
>
> Someone else said the same thing and I didn't get it. Putting "file" means
> not passing a literal "file" but the value "file" from the html form. I
see,
> said the blind man ...
>
> I'm definitely going to give the authors a piece of my mind - torturing
poor
> newbies by giving us broken example code. And this is an O'Reilly book,
too!
>
> That change allowed me to run perl -w and the only error left in my apache
> error log is a "premature end of script" so I'm sure that was it. I'll
post
> exactly what I had to change to the list after I get it working (she says
> with confidence).
>
> Thanks much!
>
> >
> > # the 'upload' subroutine has the same usage as 'param', but is used for
> > file uploads.
> > # so instead of passing $file to 'upload' you should be passing "file".
> > # (this is according to the CGI docs.) 'upload' returns a filehandle,
> while
> > 'param' returns
> > # a file name. this may be your problem.
> > my $fh = $q->upload( $file );
> >
> >
>
>
>
> --
> 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]