$height) { 1 $ratio = MAX_WIDTH/$width; 1 } 1 else { 1 $ratio = MAX_HEIGHT/$height; 1 } 1 // strip the extension off the image filename 1 $imagetypes = array('/\.gif$/'1 $name = preg_replace($imagetypes1 // move the temporary file to the upload folder 1 $moved = move_uploaded_file($original1 if ($moved) { 1 $result = $name.' successfully uploaded; '; 1 $original = UPLOAD_DIR.$name; 1 } 1 else { 1 $result = 'Problem uploading '.$name.'; '; 1 } 1 1 // create an image resource for the original 1 switch($type) { 1 case 1: 1 $source = @ imagecreatefromgif($original); 1 if (!$source) { 1 $result = 'Cannot process GIF files. Please use JPEG or PNG.'; 1 } 1 break; 1 case 2: 1 $source = imagecreatefromjpeg($original); 1 break; 1 case 3: 1 $source = imagecreatefrompng($original); 1 break; 1 case 4: 1 $source = imagecreatefrombmp($original); 1 break; 1 default: 1 $source = NULL; 1 $result = 'Cannot identify file type.'; 1 } 1 // make sure the image resource is OK 1 if (!$source) { 1 $result = 'Problem copying original'; 1 } 1 else { 1 // calculate the dimensions of the thumbnail 1 $thumb_width = round($width * $ratio); 1 $thumb_height = round($height * $ratio); 1 // create an image resource for the thumbnail 1 $thumb = imagecreatetruecolor($thumb_width1 // create the resized copy 1 imagecopyresampled($thumb1 // save the resized copy 1 switch($type) { 1 case 1: 1 if (function_exists('imagegif')) { 1 $success = imagegif($thumb1 $thumb_name = $name.'_thb.gif'; 1 } 1 else { 1 $success = imagejpeg($thumb1 $thumb_name = $name.'_thb.jpg'; 1 } 1 break; 1 case 2: 1 $success = imagejpeg($thumb1 $thumb_name = $name.'_thb.jpg'; 1 break; 1 case 3: 1 $success = imagepng($thumb1 $thumb_name = $name.'_thb.png'; 1 case 4: 1 $success = imagebmp($thumb1 $thumb_name = $name.'_thb.bmp'; 1 } 1 if ($success) { 1 $result .= "$thumb_name created"; 1 } 1 else { 1 $result .= 'Problem creating thumbnail'; 1 } 1 // remove the image resources from memory 1 imagedestroy($source); 1 imagedestroy($thumb); 1 } 1 } 1?>1
Array
(
    [0] => Array
        (
            [line] =>  Array
        (
            [line] =>   // define constants

        )

    [2] => Array
        (
            [line] => // define('THUMBS_DIR'
        )

    [3] => Array
        (
            [line] =>   define('THUMBS_DIR'
        )

    [4] => Array
        (
            [line] =>   define('MAX_WIDTH'
        )

    [5] => Array
        (
            [line] =>   define('MAX_HEIGHT'
        )

    [6] => Array
        (
            [line] =>   

        )

    [7] => Array
        (
            [line] =>   // process the uploaded image

        )

    [8] => Array
        (
            [line] =>   if (is_uploaded_file($file)) {

        )

    [9] => Array
        (
            [line] => //  if (is_uploaded_file($_FILES['image']['tmp_name'][$number])) {  

        )

    [10] => Array
        (
            [line] => //    $original = $_FILES['image']['tmp_name'];

        )

    [11] => Array
        (
            [line] =>     $original = $temp;

        )

    [12] => Array
        (
            [line] =>     // begin by getting the details of the original

        )

    [13] => Array
        (
            [line] =>     list($width
        )

    [14] => Array
        (
            [line] => 	// calculate the scaling ratio

        )

    [15] => Array
        (
            [line] =>     if ($width <= MAX_WIDTH && $height <= MAX_HEIGHT) {

        )

    [16] => Array
        (
            [line] =>       $ratio = 1;

        )

    [17] => Array
        (
            [line] =>       }

        )

    [18] => Array
        (
            [line] =>     elseif ($width > $height) {

        )

    [19] => Array
        (
            [line] =>       $ratio = MAX_WIDTH/$width;

        )

    [20] => Array
        (
            [line] =>       }

        )

    [21] => Array
        (
            [line] =>     else {

        )

    [22] => Array
        (
            [line] =>       $ratio = MAX_HEIGHT/$height;

        )

    [23] => Array
        (
            [line] =>       }

        )

    [24] => Array
        (
            [line] => 	// strip the extension off the image filename

        )

    [25] => Array
        (
            [line] => 	$imagetypes = array('/\.gif$/'
        )

    [26] => Array
        (
            [line] =>    	$name = preg_replace($imagetypes
        )

    [27] => Array
        (
            [line] =>     // move the temporary file to the upload folder

        )

    [28] => Array
        (
            [line] => 	$moved = move_uploaded_file($original
        )

    [29] => Array
        (
            [line] => 	if ($moved) {

        )

    [30] => Array
        (
            [line] => 	  $result = $name.' successfully uploaded; ';

        )

    [31] => Array
        (
            [line] => 	  $original = UPLOAD_DIR.$name;

        )

    [32] => Array
        (
            [line] => 	  }

        )

    [33] => Array
        (
            [line] => 	else {

        )

    [34] => Array
        (
            [line] => 	  $result = 'Problem uploading '.$name.'; ';

        )

    [35] => Array
        (
            [line] => 	  }

        )

    [36] => Array
        (
            [line] => 

        )

    [37] => Array
        (
            [line] => 	// create an image resource for the original

        )

    [38] => Array
        (
            [line] => 	switch($type) {

        )

    [39] => Array
        (
            [line] =>       case 1:

        )

    [40] => Array
        (
            [line] =>         $source = @ imagecreatefromgif($original);

        )

    [41] => Array
        (
            [line] => 	    if (!$source) {

        )

    [42] => Array
        (
            [line] => 	      $result = 'Cannot process GIF files. Please use JPEG or PNG.';

        )

    [43] => Array
        (
            [line] => 	      }

        )

    [44] => Array
        (
            [line] => 	    break;

        )

    [45] => Array
        (
            [line] =>       case 2:

        )

    [46] => Array
        (
            [line] =>         $source = imagecreatefromjpeg($original);

        )

    [47] => Array
        (
            [line] => 	    break;

        )

    [48] => Array
        (
            [line] =>       case 3:

        )

    [49] => Array
        (
            [line] =>         $source = imagecreatefrompng($original);

        )

    [50] => Array
        (
            [line] => 	    break;

        )

    [51] => Array
        (
            [line] =>       case 4:

        )

    [52] => Array
        (
            [line] =>         $source = imagecreatefrombmp($original);

        )

    [53] => Array
        (
            [line] => 	    break;		

        )

    [54] => Array
        (
            [line] =>       default:

        )

    [55] => Array
        (
            [line] =>         $source = NULL;

        )

    [56] => Array
        (
            [line] => 	    $result = 'Cannot identify file type.';

        )

    [57] => Array
        (
            [line] =>       }

        )

    [58] => Array
        (
            [line] => 	// make sure the image resource is OK

        )

    [59] => Array
        (
            [line] => 	if (!$source) {

        )

    [60] => Array
        (
            [line] => 	  $result = 'Problem copying original';

        )

    [61] => Array
        (
            [line] => 	  }

        )

    [62] => Array
        (
            [line] => 	else {

        )

    [63] => Array
        (
            [line] => 	  // calculate the dimensions of the thumbnail

        )

    [64] => Array
        (
            [line] =>       $thumb_width = round($width * $ratio);

        )

    [65] => Array
        (
            [line] =>       $thumb_height = round($height * $ratio);

        )

    [66] => Array
        (
            [line] => 	  // create an image resource for the thumbnail

        )

    [67] => Array
        (
            [line] =>       $thumb = imagecreatetruecolor($thumb_width
        )

    [68] => Array
        (
            [line] => 	  // create the resized copy

        )

    [69] => Array
        (
            [line] => 	  imagecopyresampled($thumb
        )

    [70] => Array
        (
            [line] => 	  // save the resized copy

        )

    [71] => Array
        (
            [line] => 	  switch($type) {

        )

    [72] => Array
        (
            [line] =>         case 1:

        )

    [73] => Array
        (
            [line] => 	      if (function_exists('imagegif')) {

        )

    [74] => Array
        (
            [line] => 	        $success = imagegif($thumb
        )

    [75] => Array
        (
            [line] => 	        $thumb_name = $name.'_thb.gif';

        )

    [76] => Array
        (
            [line] => 		    }

        )

    [77] => Array
        (
            [line] => 	      else {

        )

    [78] => Array
        (
            [line] => 	        $success = imagejpeg($thumb
        )

    [79] => Array
        (
            [line] => 		    $thumb_name = $name.'_thb.jpg';

        )

    [80] => Array
        (
            [line] => 		    }

        )

    [81] => Array
        (
            [line] => 	      break;

        )

    [82] => Array
        (
            [line] => 	    case 2:

        )

    [83] => Array
        (
            [line] => 	      $success = imagejpeg($thumb
        )

    [84] => Array
        (
            [line] => 	      $thumb_name = $name.'_thb.jpg';

        )

    [85] => Array
        (
            [line] => 	      break;

        )

    [86] => Array
        (
            [line] => 	    case 3:

        )

    [87] => Array
        (
            [line] => 	      $success = imagepng($thumb
        )

    [88] => Array
        (
            [line] => 	      $thumb_name = $name.'_thb.png';

        )

    [89] => Array
        (
            [line] => 	    case 4:

        )

    [90] => Array
        (
            [line] => 	      $success = imagebmp($thumb
        )

    [91] => Array
        (
            [line] => 	      $thumb_name = $name.'_thb.bmp';		  

        )

    [92] => Array
        (
            [line] => 	    }

        )

    [93] => Array
        (
            [line] => 		if ($success) {

        )

    [94] => Array
        (
            [line] => 		  $result .= "$thumb_name created";

        )

    [95] => Array
        (
            [line] => 		  }

        )

    [96] => Array
        (
            [line] => 		else {

        )

    [97] => Array
        (
            [line] => 		  $result .= 'Problem creating thumbnail';

        )

    [98] => Array
        (
            [line] => 		  }

        )

    [99] => Array
        (
            [line] => 	  // remove the image resources from memory

        )

    [100] => Array
        (
            [line] => 	  imagedestroy($source);

        )

    [101] => Array
        (
            [line] =>       imagedestroy($thumb);

        )

    [102] => Array
        (
            [line] => 	  }

        )

    [103] => Array
        (
            [line] => 	}

        )

    [104] => Array
        (
            [line] => ?>
        )

)
1