Hello.

I have a script that allows a user to upload images to the filesystem as part of the backend to a CGI shopping cart system has been working fine. I then added another section allowing the user to upload images for a different part of the site but this doesn't work. The code used to process the uploads is the same [0] for both upload sections and continues to work for the first upload function.

This is the code that processes the uploads for the two image upload sections:

-----------------------------------------

my $buffer    = "";
my $buffer_size = 16384;

#print "Content-type: text/plain\n\n";
open (OUTPUT, ">$filename") or die "Could not open file $filename for writing: $!";
while (read($file, $buffer, $buffer_size)) {
    print OUTPUT $buffer;
}
close OUTPUT or die "Could not close file $filename : $!";
#exit;

-----------------------------------------

$filename is a correct filename and $file is the filehandle returned from CGI.pm which parses the form input. All the ownerships and permissions on the directories that are being uploaded to are the same and I am trying to upload the same files.

I have noticed that if I include the two commented lines in the above script (the print.. and exit lines, uncommented of course) then it does successfully write the correct file. If they are commented out then the file is not written and no errors are trapped by die.

Any ideas what is goin on here? I assume that there is a problem somewhere else in the script, but the two sections calling this subroutine seem to be pretty much the same. What should I be looking for, and why does it only work with those two lines uncommented for one upload section, but works always for the other one?

Many thanks
Will


[0] actually the same code, in a subroutine.





Reply via email to