I have a form that allows a user to upload up to three images. I was using the following to make sure the image size did not exceed a certain limit, but that was when I allowed uploading one at a time. This really does not work with three because the sum of all three may exceed the allowed upper limit, but individually they do not. So, is there a way to determine what an individual component of the parameter string size is? I used the code below to determine image size, but that is after the upload. I suspect that I may have to find another way to allow uploads...

Code:
if ($ENV{'CONTENT_LENGTH'} > $loc_maxsize) { 
$error = "The image size exceeds the maximum allowed!"; 
}
Code:
##########################
## Determine size of jpg.#
##########################
sub jpegsize {
  my($JPEG) = @_;
  my($done)=0;
  my $size, $height, $width;

  read($JPEG, $c1, 1); read($JPEG, $c2, 1);
  if( !((ord($c1) == 0xFF) && (ord($c2) == 0xD8))){
    print "This is not a JPEG!";
    $done=1;
  }
  while (ord($ch) != 0xDA && !$done) {
    # Find next marker (JPEG markers begin with 0xFF)
    # This can hang the program!!
    while (ord($ch) != 0xFF) {  read($JPEG, $ch, 1); }
    # JPEG markers can be padded with unlimited 0xFF's
    while (ord($ch) == 0xFF) { read($JPEG, $ch, 1); }
    # Now, $ch contains the value of the marker.
    if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) {
      read ($JPEG, $junk, 3); read($JPEG, $s, 4);
      ($a,$b,$c,$d)=unpack("C"x4,$s);
      $height = $a<<8|$b;
      $width = $c<<8|$d;
      $done=1;
    } else {
      # We **MUST** skip variables, since FF's within variable names are
      # NOT valid JPEG markers
      read ($JPEG, $s, 2); 
      ($c1, $c2) = unpack("C"x2,$s); 
      $length = $c1<<8|$c2;
      if( ($length < 2) ){
	print "Erroneous JPEG marker length";
	$done=1;
      } else {
	read($JPEG, $junk, $length-2);
      }
    }
  }
  return ($height, $width);
}