Javascript 代码点火器+;Dropzone JS表单操作

Javascript 代码点火器+;Dropzone JS表单操作,javascript,php,mysql,codeigniter,dropzone.js,Javascript,Php,Mysql,Codeigniter,Dropzone.js,我在Codeigniter+Dropzone.js上上传图像时遇到问题。我不能将单个或多个图像上传到目录,也不能将表单提交到Mysql数据库中输入的数据上传到目录。表单上有我想要保存到MySql数据库的输入 我已经尝试过在没有Dropzone的情况下使用Codeigniter上传功能。这很有效。但它不适用于Dropzone.js。我为英语差的家伙感到抱歉。多谢各位 查看代码: <form action="<?php echo base_url('first/upload_a

我在Codeigniter+Dropzone.js上上传图像时遇到问题。我不能将单个或多个图像上传到目录,也不能将表单提交到Mysql数据库中输入的数据上传到目录。表单上有我想要保存到MySql数据库的输入

我已经尝试过在没有Dropzone的情况下使用Codeigniter上传功能。这很有效。但它不适用于Dropzone.js。我为英语差的家伙感到抱歉。多谢各位

查看代码:

<form action="<?php echo base_url('first/upload_action/'); ?>" enctype="multipart/form-data" method="POST">
<input type="text" id ="document_type" name ="document_type" />
<div class="dropzone" id="my-dropzone" name="mainFileUploader">
   <div class="fallback">
      <input name="document" type="file" multiple />
   </div>
 </div>
</form>
<div>
  <button type="submit" id="submit-all"> upload </button>
</div>
JS代码:

<script>
  Dropzone.options.myDropzone = {
    url: "<?php echo base_url('first/upload_action/') ?>",
    autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 100,
    maxFiles: 100,
    acceptedFiles: "image/*",

    init: function () {

      var submitButton = document.querySelector("#submit-all");
      var wrapperThis = this;

      submitButton.addEventListener("click", function () {
        wrapperThis.processQueue();
      });

      this.on("addedfile", function (file) {

        // Create the remove button
        var removeButton = Dropzone.createElement("<button class='btn btn-lg dark'>Remove File</button>");

        // Listen to the click event
        removeButton.addEventListener("click", function (e) {
          // Make sure the button click doesn't submit the form:
          e.preventDefault();
          e.stopPropagation();

          // Remove the file preview.
          wrapperThis.removeFile(file);
          // If you want to the delete the file on the server as well,
          // you can do the AJAX request here.
        });

        // Add the button to the file preview element.
        file.previewElement.appendChild(removeButton);
      });

      this.on('sendingmultiple', function (data, xhr, formData) {
        formData.append("document_type", $("#document_type").val());
      });
    }
  };
</script>

Dropzone.options.myDropzone={
url:“”,
自动处理队列:false,
uploadMultiple:true,
并行上传:100,
最大文件数:100,
acceptedFiles:“image/*”,
init:函数(){
var submitButton=document.querySelector(“全部提交”);
var wrapperThis=this;
submitButton.addEventListener(“单击”,函数(){
wrapperThis.processQueue();
});
this.on(“addedfile”,函数(文件){
//创建删除按钮
var removeButton=Dropzone.createElement(“删除文件”);
//收听单击事件
removeButton.addEventListener(“单击”),函数(e){
//确保单击按钮不会提交表单:
e、 预防默认值();
e、 停止传播();
//删除文件预览。
wrapperThis.removeFile(文件);
//如果还要删除服务器上的文件,
//您可以在这里执行AJAX请求。
});
//将按钮添加到文件预览元素。
file.previewElement.appendChild(removeButton);
});
this.on('sendingmultiple',函数(data、xhr、formData){
append(“document_type”,$(“#document_type”).val();
});
}
};
<script>
  Dropzone.options.myDropzone = {
    url: "<?php echo base_url('first/upload_action/') ?>",
    autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 100,
    maxFiles: 100,
    acceptedFiles: "image/*",

    init: function () {

      var submitButton = document.querySelector("#submit-all");
      var wrapperThis = this;

      submitButton.addEventListener("click", function () {
        wrapperThis.processQueue();
      });

      this.on("addedfile", function (file) {

        // Create the remove button
        var removeButton = Dropzone.createElement("<button class='btn btn-lg dark'>Remove File</button>");

        // Listen to the click event
        removeButton.addEventListener("click", function (e) {
          // Make sure the button click doesn't submit the form:
          e.preventDefault();
          e.stopPropagation();

          // Remove the file preview.
          wrapperThis.removeFile(file);
          // If you want to the delete the file on the server as well,
          // you can do the AJAX request here.
        });

        // Add the button to the file preview element.
        file.previewElement.appendChild(removeButton);
      });

      this.on('sendingmultiple', function (data, xhr, formData) {
        formData.append("document_type", $("#document_type").val());
      });
    }
  };
</script>