For one thing, you need to specify a non-default form encoding when posting files to the server. You need:
<form action="cgi-bin/concepts2.pl" method="post" enctype="multipart/form-data">

as your opening form tag. The default encoding type for HTML/HTTP forms is "application/x-www-form-urlencoded" rather than "multipart/form-data", but the latter is necessary for file upload.

Also, whenever you don't see all the output you expect, try setting autoflush. Put $|++; in somewhere near the top of your code. This applies not only to CGI programming, but to any time you are Suffering from Buffering.

Another tip to remember about CGI programming is that CGI::Carp is your friend, especially when you use it like this during debugging:

use CGI::Carp qw( fatalsToBrowser );

Be aware, though, that it gives some information away when it encounters a fatal error which could give an attacker helpful hints. Many people suggest using that feature only during development and not in production.


In reply to Re: Passing a file from a form, processing, and then outputting as html by mr_mischief
in thread Passing a file from a form, processing, and then outputting as html by bobekdj

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.