title: How to upload multiple images in CakePHP
body: <p>I am able to upload a single image in CakePHP but I want upload multiple images at once. How can I achieve it?</p>
  
  <p>My Controller page is like this:   </p>
  
  <pre><code> public function display() {
    if ($this-&gt;request-&gt;is('post')) {
              if ($this-&gt;data['Image']) {
                  $image = $this-&gt;data['Image']['image'];
                  //allowed image types
                  $imageTypes = array("image/gif", "image/jpeg", "image/png");
                  //upload folder - make sure to create one in webroot
                  $uploadFolder = "upload";
                  //full path to upload folder
                  $uploadPath = WWW_ROOT . $uploadFolder;
  
  
                  //check if image type fits one of allowed types
                  foreach ($imageTypes as $type) {
                      if ($type == $image['type']) {
                        //check if there wasn't errors uploading file on serwer
                          if ($image['error'] == 0) {
                               //image file name
                              $imageName = $image['name'];
                              //check if file exists in upload folder
                              if (file_exists($uploadPath . '/' . $imageName)) {
                                              //create full filename with timestamp
                                  $imageName = date('His') . $imageName;
                              }
                              //create full path with image name
                              $full_image_path = $uploadPath . '/' . $imageName;
                              //upload image to upload folder
                              if (move_uploaded_file($image['tmp_name'], $full_image_path)) {
                                  $this-&gt;Session-&gt;setFlash('File saved successfully');
                                  $this-&gt;set('imageName',$imageName);
                              } else {
                                  $this-&gt;Session-&gt;setFlash('There was a problem uploading file. Please try again.');
                              }
                          } else {
                              $this-&gt;Session-&gt;setFlash('Error uploading file.');
                          }
                          break;
                      } else {
                          $this-&gt;Session-&gt;setFlash('Unacceptable file type');
                      }
                  }
              }
          }
          $this-&gt;render('home');
      }
  </code></pre>
  
  <p>My view page is like this</p>
  
  <pre><code>&lt;?php
  /* display message saved in session if any */
  echo $this-&gt;Session-&gt;flash();
  ?&gt;
  &lt;div&gt; 
  &lt;div class="images-form"&gt;
  &lt;?php echo $this-&gt;Form-&gt;create('Image', array('type' =&gt; 'file')); ?&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;&lt;?php echo __('Add Image'); ?&gt;&lt;/legend&gt;
          &lt;?php
  
          echo $this-&gt;Form-&gt;input('image', array('type' =&gt; 'file'));
      ?&gt;
      &lt;/fieldset&gt;
  &lt;?php echo $this-&gt;Form-&gt;end(__('Submit')); ?&gt;
  
  &lt;/div&gt;
  &lt;div class="image-display"&gt;
  &lt;?php 
  
  //if is set imageName show uploaded picture
  
  if(isset($imageName)) {
  echo $this-&gt;Html-&gt;image('/upload/'.$imageName, array('alt' =&gt; 'uploaded image'));
  }
  ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>