Re: I have problems with download scripts, it's trying to print instead of saving the file
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 20:23:58 -0500
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;
> $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...
> 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.
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.
- Follow-Ups:
- References:
- Prev by Date: Re: Order of Elements in Hash
- Next by Date: How a JAPH script on CPAN works.
- 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):
Relevant Pages
|
|