【问题标题】:dropzone form comes in whole body.dropzone形式出现在全身。
【发布时间】:2016-03-19 11:18:09
【问题描述】:

我将这段代码用于以正常形式插入 dropzone

索引.php

        <form id="my-awesome-dropzone"  class="dropzone" action="upload.php">
          <div class="dropzone-previews"> </div> <!-- this is were the previews should be shown. -->

          <!-- Now setup your input fields -->
          <input type="text" name="Name" />
          <input type="text" name="Description" />

          <button type="submit">Submit data and files!</button>

        </form>

自定义 dropzone JS

   Dropzone.options.myAwesomeDropzone = { 
   autoProcessQueue: false,
        uploadMultiple: false,
         parallelUploads: 100,
          maxFiles: 100,


    init: function() {
var myDropzone = this;


this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {

  e.preventDefault();
  e.stopPropagation();
  myDropzone.processQueue();
});


this.on("sendingmultiple", function() {
  alert("successfully");
});
this.on("successmultiple", function(files, response) {
  alert("successfully");

});
this.on("errormultiple", function(files, response) {
  alert("Error");

});}}

请高手大哥帮帮我!下拉表格带有整个表格。我需要在这段代码中修复什么。

【问题讨论】:

    标签: javascript php jquery html dropzone.js


    【解决方案1】:

    我没有理解整个问题,但我在您的代码中只看到了几个问题。

    在下面的 sn-p 中,我更新了您的代码以查看警报消息:

    $(function () {
      Dropzone.options.myAwesomeDropzone = {
        previewsContainer: '.dropzone-previews',
        autoProcessQueue: false,
        uploadMultiple: false,
        parallelUploads: 100,
        maxFiles: 100,
        init: function () {
          var myDropzone = this;
    
          this.element.querySelector("button[type=submit]").addEventListener("click", function (e) {
            e.preventDefault();
            e.stopPropagation();
            myDropzone.processQueue();
          });
        },
        sending: function(file, xhr, formData) {
          alert('sending');
        },
        sendingmultiple: function (file, xhr, formData) {
          alert("successfully");
        },
        successmultiple: function (file, xhr, formData) {
          alert("successfully");
    
        },
        error: function (a, errorMessage, xhr) {
          alert("Error");
        }
      };
    });
    <script src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
    
    <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/dropzone.css" rel="stylesheet">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/dropzone.js"></script>
    
    <form id="my-awesome-dropzone" class="dropzone" action="upload.php">
        <div class="dropzone-previews"></div>
        <!-- this is were the previews should be shown. -->
    
        <!-- Now setup your input fields -->
        <input type="text" name="Name"/>
        <input type="text" name="Description"/>
    
        <button type="submit">Submit data and files!</button>
    
    </form>

    【讨论】:

    • 感谢您宝贵的时间!我看到你的sn-p。您是否在整个表单中看到“将文件拖放到此处以上传选项”。但我只需要它在字段上方!你能给我建议吗?请
    • @SaifMorshed 感谢您的评论。为了帮助您,我需要了解您在寻找什么。对不起,我无法理解您的“但我只需要在字段上方!”。你能好心澄清一下这个概念吗?再次感谢
    • 非常感谢您再次回复我。 “但我只需要它在田野上方!”这意味着我想说拖放工作与全身。但我只想在一个我想展示的区域工作。所以我想在字段上方显示它。
    • @SaifMorshed 现在试试,让我知道。我只添加了 previewsContainer: '.dropzone-previews',
    猜你喜欢
    • 2014-09-02
    • 2018-02-01
    • 2018-02-19
    • 2016-01-31
    • 1970-01-01
    • 2015-06-11
    • 1970-01-01
    • 2018-12-20
    相关资源
    最近更新 更多