I searched on Google for a code example of how to upload and resize an image using CakePHP and I didn't get to much results on this, so I decided to make it on my own way. First of all I created the /foto/ directory in the webroot (app/webroot) and inside it other 2 directories, one for the uploaded image /big/ (this is the big version of the image) and one for the image that will be resized /small/ (this can be the thumbnail), be sure that they have write permissions.

Now create a component called image.php and inside it you will have the code that will handle getting the file extension and resizing the uploaded image (app/controllers/components/image.php):

PHP:
  1. class ImageComponent extends Object
  2. {
  3.    function resize_img($imgname,$size)
  4.    {
  5.       //Header("Content-Type: image/jpeg");
  6.       $img_src = ImageCreateFromjpeg ($imgname);
  7.       $true_width = imagesx($img_src);
  8.       $true_height = imagesy($img_src);
  9.  
  10.       if ($true_width>=$true_height)
  11.       {
  12.         $width=$size;
  13.         $height = ($width/$true_width)*$true_height;
  14.       }
  15.       else
  16.       {
  17.        // $height=$size;
  18.        $width=$size;
  19.        $height = ($width/$true_width)*$true_height;
  20.        // $width = ($height/$true_height)*$true_width;
  21.       }
  22.         $img_des = ImageCreateTrueColor($width,$height);
  23.         imagecopyresampled ($img_des, $img_src, 0, 0, 0, 0, $width, $height, $true_width, $true_height);
  24.         return $img_des;
  25.     }
  26.  
  27.     function getFileExtension($str) {
  28.  
  29.         $i = strrpos($str,".");
  30.         if (!$i) { return ""; }
  31.         $l = strlen($str) - $i;
  32.         $ext = substr($str,$i+1,$l);
  33.         return $ext;
  34.     }
  35. }

Now let's see the view that will show the input type file element and the form (app/views/controller_name/upload.thtml):

PHP:
  1. <form method="post" enctype="multipart/form-data" action="<?php echo $this->webroot;?>images/add">
  2.     <p>
  3.        <p>Image: &nbsp; &nbsp; &nbsp; &nbsp; <?php echo $html->file('Image/name1', array('size' => '40'))?>
  4.     </p>
  5.     <p>
  6.         <?php echo $html->submit('Upload image'); ?>
  7.     </p>
  8. </form>


At the end comes the last part and the "hardest", when comes to write the controller code (app/controllers/images_controller.php):

PHP:
  1. class ImagesController extends AppController {
  2. var $components = array("Image"); // here is the image component that we described above
  3.  
  4. function add(){
  5.  
  6. if (strlen($this->data['Image']['name1']['name'])>4){
  7.  
  8.                    $error = 0;
  9.                    $uploaddir1 = "foto/big"; // the /big/ directory
  10.                    $uploaddir2 = "foto/small"; // the /small/ directory with resized images
  11.                    $filetype = $this->Image->getFileExtension($this->data['Image']['name1']['name']);
  12.                    $filetype = strtolower($filetype);
  13.  
  14.                    if (($filetype != "jpeg")  && ($filetype != "jpg"))
  15.                    {
  16.                     // verify the extension
  17.                     $error=1;
  18.                    }
  19.                    else
  20.                    {
  21.                     $imgsize = GetImageSize($this->data['Image']['name1']['tmp_name']); // image size
  22.                    }
  23.                    if (($imgsize[0]> 800) || ($imgsize[1]> 600)){
  24.                      // verify to see if the image exceds 800 x 600 px
  25.                      unlink($this->data['Image']['name1']['name']); // delete the image in case is to big
  26.                      $error=1;
  27.                     }
  28.                     if ($error==0){
  29.  
  30.                       // here is generated an unic id for the image name
  31.                       $stamp = strtotime ("now");
  32.                       $orderid = $stamp;
  33.                       $orderid = str_replace(".", "", $orderid);
  34.                       $id_unic = $orderid;
  35.                       $temp = $id_unic;
  36.                       settype($temp,"string");
  37.                       $temp.= ".";
  38.                       $temp.=$filetype;
  39.                       $newfile = $uploaddir1 . "/$temp";
  40.                     if (is_uploaded_file($this->data['Image']['name1']['tmp_name']))
  41.                     {
  42.                         if (!copy($this->data['Image']['name1']['tmp_name'],"$newfile"))
  43.                         {
  44.                             print "Error Uploading File1.";
  45.                             exit();
  46.                         }
  47.                     }
  48.                     $newfile2 = $uploaddir2 . "/$temp";
  49.  
  50.                      $picture_location=$newfile;
  51.                      $size=110; // the size for the resized image
  52.                      $img_des= $this->Image->resize_img($picture_location, $size); //here resizing
  53.                      imagejpeg($img_des,$newfile2,80);
  54.  
  55.                      // here you can have some code for example to insert in the database
  56.                      // Image uploaded
  57.                    }
  58.               }else{
  59.                       // Image not uploaded
  60.               }
  61.      }
  62. }

This is all.
This script above need to have GD installed on the server.