Hi there, I am in need of a little bit of help. I am attempting to write a file up-load CGI script to go with a form I've written, and I can't seem to get the file up-load to work properly.

Let me show you what I mean, the code below is the up-load section of a test CGI script I wrote:

my ( $fil, $bts, $bfr, $dta, $tru, ); $fil = $cgi->param('file'); while ($bts = read($fil, $bfr, 1024) || croak "Oops! $!") { $dta .= $bfr; } $hdr = $cgi->header({type=>"text/html"}); $cnt .= $cgi->start_html(); $cnt .= $cgi->p("Here's the data: "); $cnt .= $dta; $cnt .= $cgi->end_html(); print $hdr, $cnt; exit 0;

Now ... when the form is submitted, the script croaks with this error:

"Software error: Oops! Bad file descriptor at test.cgi line 30" ... "Bad file descriptor"

it happens with .txt files, .doc files, .jpg files, etc.

Could someone kindly fill me in on what exactly I'm doing wrong? I'd appreciate your time.

The web serever is Apache2, running on Kubuntu Linux Dapper Drake.

Thank you again for you time, I'm stumped.

-s0up

Code tags added by GrandFather

Visit us at crazylogic.org #apartment411 D A R K E M P I R E s u b n e t w o r k

In reply to Up-Loading Files From Multi-Part Form by SoupNazi

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.