• <small id='NKPvO'></small><noframes id='NKPvO'>

  • <i id='NKPvO'><tr id='NKPvO'><dt id='NKPvO'><q id='NKPvO'><span id='NKPvO'><b id='NKPvO'><form id='NKPvO'><ins id='NKPvO'></ins><ul id='NKPvO'></ul><sub id='NKPvO'></sub></form><legend id='NKPvO'></legend><bdo id='NKPvO'><pre id='NKPvO'><center id='NKPvO'></center></pre></bdo></b><th id='NKPvO'></th></span></q></dt></tr></i><div id='NKPvO'><tfoot id='NKPvO'></tfoot><dl id='NKPvO'><fieldset id='NKPvO'></fieldset></dl></div>
  • <tfoot id='NKPvO'></tfoot>
    <legend id='NKPvO'><style id='NKPvO'><dir id='NKPvO'><q id='NKPvO'></q></dir></style></legend>

          <bdo id='NKPvO'></bdo><ul id='NKPvO'></ul>

        使用 dropzone 向后端发送附加数据

        时间:2024-08-09
      1. <legend id='cIUtb'><style id='cIUtb'><dir id='cIUtb'><q id='cIUtb'></q></dir></style></legend>

        <small id='cIUtb'></small><noframes id='cIUtb'>

        • <i id='cIUtb'><tr id='cIUtb'><dt id='cIUtb'><q id='cIUtb'><span id='cIUtb'><b id='cIUtb'><form id='cIUtb'><ins id='cIUtb'></ins><ul id='cIUtb'></ul><sub id='cIUtb'></sub></form><legend id='cIUtb'></legend><bdo id='cIUtb'><pre id='cIUtb'><center id='cIUtb'></center></pre></bdo></b><th id='cIUtb'></th></span></q></dt></tr></i><div id='cIUtb'><tfoot id='cIUtb'></tfoot><dl id='cIUtb'><fieldset id='cIUtb'></fieldset></dl></div>

              • <bdo id='cIUtb'></bdo><ul id='cIUtb'></ul>
                <tfoot id='cIUtb'></tfoot>
                    <tbody id='cIUtb'></tbody>
                  本文介绍了使用 dropzone 向后端发送附加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试通过 dropzone 将图像文件的特定 - 已经知道 - 位置 ID 发送到后端,该 ID 将上传到服务器上.虽然正在使用 formData.append(),但我看到没有附加任何内容.而只是显示了这个FormData {}".

                  I am trying to send through dropzone a specific -already known- position ID of an image file to the backend, which is going to be uploaded on the server. Although the formData.append() is being used, I see that nothing is appended.Instead just this "FormData {}" shows up.

                  dropzoneObject.on("sending", function(file, xhr, formData){
                      var nameOfFile = $(file.previewElement).find(".dz-filename").text();
                      var positionOfFile = fpos;
                      //console.log("The file who's being sent is named: "+nameOfFile+" and its position id is: "+positionOfFile);
                      formData.append("fpos", fpos);
                  });
                  

                  我希望在示例中看到 fpos=16;

                  I expect to see in example fpos=16;

                  推荐答案

                  不知道你的具体错误,但这里有一个简单的例子,说明如何使用 jQuery 使用 dropzone 发送附加数据并在后端使用 php 接收它.

                  Don't know about your particular error, but here is a simple example of how to send additional data with dropzone using jQuery and receiving it with php on the backend.

                  html:

                  <form id="myForm" class="dropzone"></form>
                  

                  js:

                  Dropzone.autoDiscover = false;
                  $('.dropzone').dropzone ({
                          url: "upload.php",
                          init: function() {
                              this.on("sending", function(file, xhr, formData){
                                  formData.append("fpos", 777)
                              }),
                              this.on("success", function(file, xhr){
                                  alert(file.xhr.response);
                              })
                          },
                  });
                  

                  成功事件只是为了演示如何访问服务器发送的响应:

                  The success event is only to demonstrate how to access the response send from the server:

                  php:

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

                  php 只是将接收到的相同数据发送回客户端,只是为了显示可访问的位置.

                  The php simply sends back to client the same data received, just to show where is accessible.

                  这篇关于使用 dropzone 向后端发送附加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在通过ajax加载的html中运行javascript 下一篇:chrome 扩展上的 Access-Control-Allow-Origin

                  相关文章

                1. <legend id='FuZuC'><style id='FuZuC'><dir id='FuZuC'><q id='FuZuC'></q></dir></style></legend>
                  <tfoot id='FuZuC'></tfoot>
                    <i id='FuZuC'><tr id='FuZuC'><dt id='FuZuC'><q id='FuZuC'><span id='FuZuC'><b id='FuZuC'><form id='FuZuC'><ins id='FuZuC'></ins><ul id='FuZuC'></ul><sub id='FuZuC'></sub></form><legend id='FuZuC'></legend><bdo id='FuZuC'><pre id='FuZuC'><center id='FuZuC'></center></pre></bdo></b><th id='FuZuC'></th></span></q></dt></tr></i><div id='FuZuC'><tfoot id='FuZuC'></tfoot><dl id='FuZuC'><fieldset id='FuZuC'></fieldset></dl></div>
                      <bdo id='FuZuC'></bdo><ul id='FuZuC'></ul>
                  1. <small id='FuZuC'></small><noframes id='FuZuC'>