Greetings Wise Ones

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:

#!/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;
And now the error:

[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
I'm confused as the manpage says that $filename = $query->upload('uploaded_file');, $filename is also a file handle.

Can someone give me a nudge in the right direction?

Thanks

ReTard (not the quickest function in the library)


In reply to Problem with file upload CGI script by reTard

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.