如何在单击提交按钮时让Dropzone.js上传文件?

在过去的几天里,我一直在尝试将Dropzone应用到我的表单中,但到目前为止,我没有运气,只有在单击提交按钮时才能确定如何上传和处理图像。 所以,我决定来这里问你们帮忙。
我已经制作了一个示例代码结构,所以你只能看看它的必要性。 现在,我认为当我将一些图片放入Dropzone并点击它从控制器触发collect_input函数的按钮时,它应该是正常的。 但我不知道如何处理文件等。 所以, 我想我要求的是如何从表单处理文件的提示/解决方案,例如。 将它们保存到文件夹并将条目添加到数据库。
我将在下面发布代码,如果您有任何提示或解决方案,请与我分享。 我想提前感谢大家阅读本文和回复。 顺便说一下,我在CodeIgniter工作。
[下载整个项目(css,js&php) http://puu.sh/5eqLc.zip

的htdocs /应用/控制器/ test.php的

load->view('test_view'); } public function collect_input() { } } 

的htdocs /应用/控制器/ test_view.php

    Test    <link href="/css/basic.css" type="text/css" rel="stylesheet" /> <link href="/css/dropzone.css" type="text/css" rel="stylesheet" /> <script src="js/dropzone.min.js">  jQuery(document).ready(function() { var myDropzone = new Dropzone("div#myId", { url: "file-upload"}); });   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. }); } };       Chooose a type >>Type A >>Type B   

您可以提供自己的url来上传文件。 目前我只是把它设为'someurl'

 Dropzone.autoDiscover = false; jQuery(document).ready(function() { var myDropzone = new Dropzone("#myId", { url: 'someurl', autoProcessQueue:false }); $('#add').on('click',function(e){ e.preventDefault(); myDropzone.processQueue(); }); });