Re: I have problems with download scripts, it's trying to print instead of saving the file
- From: "E Arredondo" <atk@xxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 19:05:12 GMT
"Tad McClellan" <tadmc@xxxxxxxxxxxxxx> wrote in message
news:slrndjp4te.85j.tadmc@xxxxxxxxxxxxxxxxxxxxxxx
>E Arredondo <atk@xxxxxxxxxxxxx> wrote:
>
>> #!/usr/bin/perl -w
>>
>> use CGI;
>
>
> You are missing a line that should be included in all of your Perl
> programs:
>
> use strict;
>
I'm getting this on the log file after adding the strict command:
Global symbol "$query" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 11.
Global symbol "$upload_dir" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 13.
Global symbol "$filename" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 13.
Global symbol "$upload_dir" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 14.
Global symbol "$filename" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 14.
Global symbol "$upload_filehandle" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 16.
Global symbol "$query" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 22.
Global symbol "$claim" requires explicit package name at
/usr/lib/apache/cgi-bin/upload.cgi line 23.
Execution of /usr/lib/apache/cgi-bin/upload.cgi aborted due to compilation
errors.
[Fri Sep 30 11:57:15 2005] [error] [client 69.239.42.161] Premature end of
script headers: /usr/lib/apache/cgi-bin/upload.cgi
>
>> $filename = $query->param("photo");
>> $filename =~ s/.*[\/\\](.*)/$1/;
>
>
> perldoc File::Basename
>
>
>> $upload_filehandle = $query->upload("photo");
>
>
> That variable contains a *string*, not a filehandle...
>
>
>> open UPLOADFILE, ">$upload_dir/$filename";
>
>
> You should always, yes *always*, check the return value from open():
>
> open UPLOADFILE, ">$upload_dir/$filename" or
> die "could not open '$upload_dir/$filename' $!";
>
>
>> while ( <$upload_filehandle> )
>
>
> You need to put an _actual_ filehandle inside the input operator.
>
>
>><HEAD>
>><TITLE>Thanks!</TITLE>
>><HEAD>
>><TITLE>Thanks!</TITLE>
>></HEAD>
>
>
> That is a rather bizarre document structure...
>
>
I screwed up when copying and pasting from my ssh window. sorry
>> And here's the log file :
>> binmode() on closed filehandle UPLOADFILE at
>
>
> Your open() failed, but you didn't know it because you did
> not check its return value.
>
>
I got it! Thanks!!! for your comments
> --
> Tad McClellan SGML consulting
> tadmc@xxxxxxxxxxxxxx Perl programming
> Fort Worth, Texas
.
- References:
- Prev by Date: Re: equality as a variable
- Next by Date: Re: I have problems with download scripts, it's trying to print instead of saving the file
- Previous by thread: Re: I have problems with download scripts, it's trying to print instead of saving the file
- Next by thread: Re: I have problems with download scripts, it's trying to print instead of saving the file
- Index(es):