title: How to get Dropzone.js to upload files only when a submit button is clicked?
body: <p>for the past few days I've been trying to implement Dropzone into my form, but so far I had no luck figuring out how to make it upload and process the images only when the submit button gets clicked.
  Therefore, I decided to come here and ask you guys for help. 
  <br>
  I've made a example code structure so you can only take a look at what its necessary. Right now, I think its should work the way when I put some pictures into the Dropzone and click the button it triggers the collect_input function from the controller. But I have no clue how to process the files,etc. So, <strong>I guess what I'm asking for is a tip/solution on how to process the files from the form e.g.. Saving them to a folder and adding an entry to a database.</strong>
  <br>
  I'm gonna post the code below and if any of you have any tips or solutions please share them with me. I'd like to thank you all in advance for even reading this and for your replies. Btw I'm working in CodeIgniter.
  <br>
  [Download the whole project (css,js &amp; php] <a href="http://puu.sh/5eqLc.zip">http://puu.sh/5eqLc.zip</a>
  <br>
  <br>
  <b>htdocs/application/controllers/test.php</b></p>
  
  <pre><code>&lt;?php
  class Test extends CI_Controller {
  
      public function __construct() {
  
          parent::__construct();
  
  
      }
  
      public function index() {
  
          $this-&gt;load-&gt;view('test_view');
  
      }
  
      public function collect_input() {
      }
  }
  </code></pre>
  
  <p><b>htdocs/application/controllers/test_view.php</b></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Test&lt;/title&gt;
          &lt;meta charset="utf=8"&gt;
          &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;                      
  
              &lt;!--    Load DropZone        --&gt;
              &lt;link href="&lt;?php echo base_url(); ?&gt;/css/basic.css" type="text/css" rel="stylesheet" /&gt;
              &lt;link href="&lt;?php echo base_url(); ?&gt;/css/dropzone.css" type="text/css" rel="stylesheet" /&gt;
              &lt;script src="&lt;?php echo base_url(); ?&gt;js/dropzone.min.js"&gt;&lt;/script&gt;
              &lt;script type="text/javascript"&gt;
                  jQuery(document).ready(function() 
                  {
                      var myDropzone = new Dropzone("div#myId", { url: "file-upload"});
                  });
              &lt;/script&gt;
              &lt;script type="text/javascript"&gt;
              Dropzone.options.myId = {
  
                // Prevents Dropzone from uploading dropped files immediately
                autoProcessQueue: false,
  
                init: function() {
                  var submitButton = document.querySelector("#add")
                      myDropzone = this; // closure
  
                  submitButton.addEventListener("click", function() {
                    myDropzone.processQueue(); // Tell Dropzone to process all queued files.
                  });
  
                  // You might want to show the submit button only when 
                  // files are dropped here:
                  this.on("addedfile", function() {
                    // Show submit button here and/or inform user to click it.
                  });         
                }
              };
              &lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
  
              &lt;?php echo form_open('test/collect_input'); ?&gt;
  
                  &lt;!-- One of the many inputs of my form --&gt;
                  &lt;select id="list_type"&gt;
                     &lt;option value="-1"&gt;Chooose a type&lt;/option&gt;
  
                     &lt;option value="1"&gt;&amp;gt;&amp;gt;Type A&lt;/option&gt;
                     &lt;option value="2"&gt;&amp;gt;&amp;gt;Type B&lt;/option&gt;
                  &lt;/select&gt;
  
                  &lt;!--        Dropzone         --&gt;
                  &lt;div id="myId" class="dropzone"&gt;&lt;/div&gt;  
  
                  &lt;!-- Submit button--&gt;
                  &lt;input type="submit" id="add" name="add" value="Add!!"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>