in reply to Uploading an image
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).
|
|---|