title: Uploading multiple files using Javascript
body: <p>Is there any way to do this ? I mean to upload multiple files in to files folder ?</p>
  
  <p>At the moment I have this, But here I can upload only one File, :</p>
  
  <p><img src="https://i.stack.imgur.com/40uP7.jpg" alt="enter image description here"></p>
  
  <p>But what I want to do is this (If u click this little +, then coming new input, where u can choose another file.) :</p>
  
  <p><img src="https://i.stack.imgur.com/NC7er.jpg" alt="enter image description here"></p>
  
  <p><strong>Uploadfile VIEW Code</strong></p>
  
  <pre><code>&lt;div class="users view"&gt;
  &lt;h2&gt;&lt;?php echo __('Lisa Fail'); ?&gt;&lt;/h2&gt;
      &lt;?php
  echo $this-&gt;Form-&gt;create('uploadFile', array( 'type' =&gt; 'file'));
  echo $this-&gt;Form-&gt;input('pdf_path', array('type' =&gt; 'file','label' =&gt; ''));
  //echo $this-&gt;Form-&gt;input('files.', array('type' =&gt; 'file', 'multiple'));
  echo $this-&gt;Form-&gt;end('Upload file');
  $image_src = $this-&gt;webroot.'files/'.$image;
  </code></pre>
  
  <p><strong>Uploadfile CONTROLLER Code</strong></p>
  
  <pre><code>public function uploadFile() {
              $filename = '';
              if ($this-&gt;request-&gt;is('post')) { // checks for the post values
          $uploadData = $this-&gt;data['uploadFile']['pdf_path'];
                  if ( $uploadData['size'] == 0 || $uploadData['error'] !== 0) { // checks for the errors and size of the uploaded file
                      return false;
                  }
                  $filename = basename($uploadData['name']); // gets the base name of the uploaded file
                  $uploadFolder = WWW_ROOT. 'files';  // path where the uploaded file has to be saved
                  $filename = time() .'_'. $filename; // adding time stamp for the uploaded image for uniqueness
                  $uploadPath =  $uploadFolder . DS . $filename;
                  if( !file_exists($uploadFolder) ){
                      mkdir($uploadFolder); // creates folder if  not found
                  }
                  if (!move_uploaded_file($uploadData['tmp_name'], $uploadPath)) {
                      return false;
                  } 
  
              }
             $this-&gt;set('image',$filename); 
  
      }
  </code></pre>
  
  <p>I have one Javascript, maybe I can use this , or not (What this is doing?: Its doing same thing, but its doing number input, where u can type a number) ?</p>
  
  <pre><code>var lastRow=0;
  function addNumber() { 
  $("#mytable tbody&gt;tr#number0").clone(true).attr('id','lisanumbrid'+lastRow).removeAttr('style').insertBefore("#mytable tbody&gt;tr#trAdd"); 
  $("#lisanumbrid"+lastRow+" button").attr('onclick','removeNumber('+lastRow+')'); 
  $("#lisanumbrid"+lastRow+" input:first").attr('numbrid','data[Lisanumbrid]['+lastRow+'][lisanumbrid]').attr({'id':'numbridlisaNumber'+lastRow,'name': 'data[Kontaktid][lisanumbrid]['+ lastRow +']'}); 
  lastRow++; 
  }
      function removeNumber(x) {
          $("#lisanumbrid"+x).remove();
      }
  </code></pre>
  
  <p>and in view file I have this, to use this js:</p>
  
  <pre><code>&lt;table id="mytable"&gt;
          &lt;tr id="number0" style="display:none;"&gt;
              &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;button('&amp;nbsp;-&amp;nbsp;',array('type'=&gt;'button','title'=&gt;'Click Here to remove this number')); ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('lisanumbrid', array ('name'=&gt;'data[Kontaktid][lisanumbrid][0]')) ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr id="trAdd"&gt;&lt;td&gt; &lt;?php echo $this-&gt;Form-&gt;button('+',array('type'=&gt;'button','title'=&gt;'Click Here to add another number','onclick'=&gt;'addNumber()')); ?&gt; &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;?php echo $this-&gt;Html-&gt;script('addNumber');
  </code></pre>
  
  <p>Can somebody help me and give some clue or solution, Is that possible to use this Javascript ?</p>
  
  <p>Thank you very much !</p>