In the future please try reducing your code to a simple test case. Few of us have the time to go through this amount of code to try and identify a problem. In any case, this might be where your problem is:

while (my $bytesread = read(READFILE, my $buffer, 1024)) { syswrite(OUTFILE, my $buffer, 1024); }

It looks like you're localizing $buffer within the while loop, which has the effect of setting it to 'undef' before you write anything out. Get rid of that second 'my' within your loop. You've already declared $buffer.

I also noticed some strange stuff in your code that either is causing you problems or probably will:

if ($file ne "" & $file =~ /image/){

Did you mean && here? Also (and more seriously):

if(open(OUTFILE, "> $TEMP_DIR/$html_lead$file$file_ext") ...

Be sure this line runs cleanly with taint-checking (-T) enabled. It looks to me like you might be opening yourself up to a very serious security problem, but I haven't examined the code too closely to know whether or not you've adjusted for this. See this recent reply I made to someone making a very similar mistake: Re: Using Variables in Path Names

I'm sure I don't have to say it, but make sure you're running with strict and warnings enabled, and in this case, taint-checking would be very helpful as well (see perlsec).


In reply to Re: Uploading an image by Fastolfe
in thread Uploading an image by MadPogo

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.