reTard has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write an image gallery but it's not quite working for me. I'm following the CGI.pm manpage. At the moment, when I run the script through the webpage I get a weird error.
First the code:
And now the error:#!/usr/bin/perl use strict; use warnings; use CGI qw /normal/; use File::Basename; my $query = CGI->new(); my $bytesread; my $buffer; my $filename; print $query->header; print $query->start_html; print $query->start_form; print $query->br; print "Enter picture description"; print $query->br; print $query->textfield(-name=>'name', -default=>'description', -size=>50, -maxlength=>250); print $query->br; print "Enter filename to upload"; print $query->br; print $query->filefield(-name=>'uploaded_file', -default=>'starting value', -size=>50, -maxlength=>80); print $query->submit; $filename = $query->upload('uploaded_file'); while (<$filename>) { print "$_<br>"; } open (OUTFILE,">/tmp/feedback"); while ($bytesread=read($filename,$buffer,1024)) { print OUTFILE $buffer; } print $query->end_html;
I'm confused as the manpage says that $filename = $query->upload('uploaded_file');, $filename is also a file handle.[Fri Aug 13 23:08:33 2004] [error] [client 192.168.1.3] Use of uniniti +alized value in <HANDLE> at /var/www/cgi-bin/gallery/upload.cgi line +37., referer: http://www.retard.com/cgi-bin/gallery/upload.cgi [Fri Aug 13 23:08:33 2004] [error] [client 192.168.1.3] readline() on +unopened filehandle at /var/www/cgi-bin/gallery/upload.cgi line 37., +referer: http://www.retard.com/cgi-bin/gallery/upload.cgi [Fri Aug 13 23:08:33 2004] [error] [client 192.168.1.3] Can't use an u +ndefined value as a symbol reference at /var/www/cgi-bin/gallery/uplo +ad.cgi line 42., referer: http://www.retard.com/cgi-bin/gallery/uploa +d.cgi
Can someone give me a nudge in the right direction?
Thanks
ReTard (not the quickest function in the library)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with file upload CGI script
by davorg (Chancellor) on Aug 13, 2004 at 15:22 UTC | |
|
Re: Problem with file upload CGI script
by eric256 (Parson) on Aug 13, 2004 at 15:23 UTC | |
|
Re: Problem with file upload CGI script
by nikos (Scribe) on Aug 13, 2004 at 17:01 UTC | |
|
Re: Problem with file upload CGI script
by tinita (Parson) on Aug 14, 2004 at 12:50 UTC |