title: How to upload multiple image in cakephp?
body: <p>I have a problem in loading multiple image, I can only load single image and when I select the next image the previous image get lost.</p>
  
  <p>My view page is like this:</p>
  
  <pre><code>&lt;div id="for_image0" class="inline-form" style="display:none;"&gt;
      &lt;span&gt;
          &lt;input type='file' name="data[ReportManagement][imageUploader]" id="file_upload" onchange="readURL(this);" /&gt;
          &lt;span id="extension_error" style="color:red;"&gt;&lt;/span&gt;
          &lt;br/&gt;
      &lt;/span&gt;         
      &lt;span id="previewPane"&gt;
          &lt;img style="width:150px;float:left;" id="img_prev" src="#" /&gt;
          &lt;span id="x" class="delete-icon" style="display:none;"&gt;&lt;?php echo $this-&gt;Html-&gt;image('close.png',array('width'=&gt;'23px')); ?&gt;&lt;/span&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>main view page:</p>
  
  <pre><code>&lt;div id="for_image0" class="inline-form" style="display:none;"&gt;
      &lt;span&gt;
          &lt;input type='file' name="data[ReportManagement][imageUploader]" id="file_upload" onchange="readURL(this);" /&gt;
          &lt;span id="extension_error" style="color:red;"&gt;&lt;/span&gt;
          &lt;br/&gt;
      &lt;/span&gt;
      &lt;span id="previewPane"&gt;
          &lt;img style="width:150px;float:left;" id="img_prev" src="#" /&gt;
          &lt;span id="x" class="delete-icon" style="display:none;"&gt;&lt;?php echo $this-&gt;Html-&gt;image('close.png',array('width'=&gt;'23px')); ?&gt;&lt;/span&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>controller page:</p>
  
  <pre><code>if(!empty($this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]['name'])){
      //debug($this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]);
      $image_type = @getimagesize($this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]['tmp_name']);
      $file_type = array('image/jpeg','image/gif','image/png','image/bmp');
      if(!in_array($image_type['mime'],$file_type)){
          return 1;
          exit;
      }           
      $name = $this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]['name'];
      $tmp_name = $this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]['tmp_name'];
      $random_number = $this-&gt;Smart-&gt;random_code();
  
      if(file_exists(WWW_ROOT.'issuereports/'.$name)){
          $name= $random_number.$this-&gt;request-&gt;data['ReportManagement']['imageUploader'.$i]['name']; 
      }
  } else {
      $name = '';
  }   
  </code></pre>