dropzone post文件和数据

时间:2016-12-23 08:39:48

标签: php dropzone.js

我发送文件时遇到问题,最后这些文件不发布

<div class="container"><form role="form" method="post" action="upload.php" class="dropzone" id="mydropzone" enctype="multipart/form-data">
<input type="hidden" name="additionaldata" value="1" /> 
<div class="form-group">
  <label  for="email">De</label>
  <input type="email" class="form-control "  name="email" placeholder="user@example.com" required />
  <span class="icon fa fa-envelope fa-lg"></span>
</div>
<div class="form-group">
  <label for="sub">Sujet</label>
  <input type="text" class="form-control "  name="sujet" placeholder="Sujet" required/>
  <span class="icon fa fa-pencil fa-lg"></span>
</div>
<div class="form-group">
  <textarea rows="5" cols="30"  name="msg" placeholder="Bonjour, insérer votre Message" style="width:100%"></textarea>
  <span class="icon-textarea fa fa-paper-plane fa-lg "></span>
</div>
<div class="dropzone-previews"></div>
<div><button id="submit-all" type="submit" class="btn btn default">Submit</button>
</div>
</form>

和我的配置dropzone

Dropzone.options.mydropzone = {        
        url: "upload.php" ,
        paramName: "file",
        previewsContainer: "#dropzone-previews", 
        autoProcessQueue: false,
        uploadMultiple: true, 
        addRemoveLinks:true,
        parallelUploads: 100,
        maxFiles: 100,
        acceptedFiles:".jpeg, .jpg, .jpe, .bmp, .png, .gif, .ico, .tiff, .tif, .svg, .svgz, \n\
                       .doc,.docx,.txt, .pdf,.rtf,.xlsx,.xls,.csv, .ppt,\n\
                       .zip,.zipx,.tar,.gz,.z,.rar",
    init: function () {
    var submitButton = document.querySelector("#submit-all") 
    var myDropzone = this;

submitButton.addEventListener("click", function() {
myDropzone.processQueue(); 
});
this.on("sendingmultiple", function() {
});
this.on("successmultiple", function(files, response) {
     });
this.on("errormultiple", function(files, response) {
});
}
}

my upload.php for check post

<?php

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') 
{
    echo "RECEIVED ON SERVER: \n";
    echo "FILES: \n";
    print_r($_FILES);
    echo "\$_POST: \n";
    print_r($_POST);
}

我很好地指向了页面上传,但最后这个仍然是空白的,没有发送 谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

您需要在your js filessuccessmultiple个事件中访问服务器的响应:

例如,要在控制台中显示响应:

errormultiple