I'm trying to upload a file to a website via CGI.pm to be processed, but I can't get it to work. I followed the documentation and the advice I found on some older posts. I would appreciate if someone can tell me what I'm doing wrong:

Portion of form that asks for the file to upload
Tr( { -style => "background-color:#CCCCCC" }, td( strong( "Enter the file you want to upload" ) ), td( filefield( { -name=>'file', -default=>'starting value', -size=>30, -maxlength=>80 } ) ), #end td ), #end Tr


Script that processes the file
#!/usr/bin/perl -w use strict; use CGI::Carp 'fatalsToBrowser'; use CGI qw/:standard/; my @lines; my $filehandle = upload('file') or die "No file uploaded!"; my $message1 = "<u>The Following Data was inserted into the Database < +/u>"; do_work(); display_page("$message1"); sub do_work { while (<$filehandle>){ push (@lines, $_); } } sub display_page { my $message = "$_[0]"; print header, start_html( "-title" => "Results Page"), p("&nbsp;"), p( strong( $message ) ), p("&nbsp;"), p("@lines"), end_html; }


I keep getting the error message "No File Uploaded!"

Thanks,
Dru
Another satisfied monk.

In reply to Uploading a File with CGI.pm by dru145

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.