Ok, Gurus and Monks I need your wisdom, yet again :o(

I'm trying to upload a image file, here is my code:
$file_name_to_add = $in{up_banner}; $file_name_to_add =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $ctype = $in{up_banner}; $ctypeb = $in{up_banner}; if ($ctype =~ /([^\/\\]+)$/) {#check if it as \ and / for valid path; $file_name_to_add = $1; $file_name_to_add =~ s/^\.+//; #remove the unwanted / or \ } # Check for File Extensions... (I'm renaming the uploaded # file to a database name that I've retrieved and stored # in the variable $record_id if ($file_name_to_add =~ m/\.gif$/i) { $file_ext = ".gif"; } elsif ($file_name_to_add =~ m/\.jpg$/i) { $file_ext = ".jpg"; } elsif ($file_name_to_add =~ m/\.jpeg$/i) { $file_ext = ".jpg"; } elsif ($file_name_to_add =~ m/\.png$/i) { $file_ext = ".png"; } else { $file_ext = ".gif"; # Default } $record_id .= $file_ext; # Append with the extension. open(OUT,">/home/user/dir/aff/pics/$record_id") or error("Can't open o +utfile (/home/user/dir/aff/pics/$record_id) for writing: $!"); $flen = 0; while (read($ctypeb,$i,1024)) { print OUT $i; $flen = $flen + 1024; } close(OUT); $page_content .= qq~ Length: ,$flen/1024,Kb<br />\n File was saved as $record_id!<br />\n<br />~;

So when it uploads the file, it gets the proper name, but then it's an empty file. 0 size. So it's not really writing the image to the file.

Any Ideas?

thx,
Richard

In reply to Uploading a image... by powerhouse

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.