I've also had trouble with this. There's a bit of disconnect between the docs I've read and the behavior I've actually managed to get working. Here's my test code that simply displays the image to the browser:
#!/usr/bin/perl -wT use strict; use CGI qw (:standard); use CGI::Carp qw( fatalsToBrowser ); my $filename; if (defined($filename = param('filename'))) { my $upload = upload('file'); print header(-type=>uploadInfo($upload)->{'Content-Type'}); print while <$upload>; } else { print header(); print <<HTML; <html><body bgcolor="#ffffff"> <form method="POST" enctype="multipart/form-data"> <input type="text" name="filename"><p> <input type="file" name="file"><p> <input type="submit"> </form> HTML }
The big difference in this code is that I used the name of the upload parameter instead of the filename when calling upload(). Contrary to what the Mouse book says, this works for me.

For what it's worth, I'm using CGI.pm 2.68, so this may have changed slightly in a newer version. The only mention of uploads in the ChangeLog is of a one-character bug squashed in 2.74. Your mileage may vary.


In reply to Re: CGI.pm file upload freaking me out by chromatic
in thread CGI.pm file upload freaking me out by Trimbach

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.