Hello,

got a script that uploads images, and have used the same coding before with no problems, worked like a charm.

But for some reason, when I use this coding now, it produces a '0' bytes size image, the image is upload OK, in the proper folder, the correct image name is created, but it's zero bytes in file size.

Below is the sub routine that uploads the images. Everything goes through fine, no errors at all. Is there something on the server that maybe causing this, they got plenty of disc space on the machine. Uploads are not disabled in the CGI.pm... I'm lost as to what I've missed. Any help would be much appreciated.

##########################################################################
# Upload file routine
sub ImageUpload {
my($subfolder,$binary_image) = @_;

unless(length($binary_image)>2) {
Error("The was a problem encounter while uploading banner image<br>Banner Image: $binary_image");
}
my @ext = split(/\,/,$conf->{allowimages});
my $match = 0;
my $limit = $conf->{maxkbimage};


my($bytesread,$buffer,$image_name,$filesize,$newImage_file);

$image_name   = $binary_image;
$image_name   =~ s!^.*(\\|\/)!!;
chomp $image_name;

$newImage_file = $subfolder . $image_name;

for my $ext (@ext)
{
if (grep /$ext$/i,$image_name) { $match = 1; last; }
}

unless($match)
{
Error("Your upload file does not appear to be in the allowed image format!.");
}


open (OUTFILE,">$newImage_file") or Error("Could not open folder: $newImage_file. Reason: $!");

   binmode OUTFILE;
   while ($bytesread = read($binary_image, $buffer, 1024)) {
   print OUTFILE $buffer or Error("Could not save file. Reason: $!");
   }
   close (OUTFILE);
   chmod 0666, $newImage_file;

   $filesize = sprintf "%0.2f",(-s $newImage_file) / 1024;

if ($filesize > $limit)
{
unlink $newImage_file;
Error("FileSize: $filesize<br>Your Image exceeds the filesize limit of $limit KB's allowed");
}


   if (!-B $newImage_file)
      {
        unlink $newImage_file;
        Error("Your Image does not appear to be in a valid binary format");
      }
# INSERTED print out here to verify the correct data is being passed and its
# fine

   print $cgi->header();
   print qq~Upload Image: $binary_image<br>~; # OK
   print qq~Image File: $newImage_file<br>~;  # OK
   print qq~Process Completed~;
   exit();

}

--
Mike<mickalo>Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to