This works for me, hope its some help to you.

open (OUTPUT,">$outfile") || die "Cannot open image file: $!"; binmode(OUTPUT); my $buffer; while (my $bytesread = read($filename_thumbnail, $buffer, 4096)) { my $length += $bytesread; print OUTPUT $buffer || die "Cannot write the image to file: $!"; } close OUTPUT || die "Cannot close image file: $!"; my $koko = int(($length+512)/1024); my $maxsize="1024"; if($koko > $maxsize && $maxsize > 0) { unlink "$outfile"; print "File size is limited to ". $maxsize ."KB<br>$koko"; }

Then the form should look like this

<form name="additem" method="post" action="$ENV{'SCRIPT_NAME'} enctype +="multipart/form-data"> <input type="file" name="outfile" size="10" class="submit"> <input type="submit"> </form>

I kinda missed out some usual CGI and perl bits there, but I hope that's some help to you.

Cheers,
Tom


In reply to Re: Upload a file from a web form by CodeJunkie
in thread Upload a file from a web form by bodmin

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.