在回退时让 dropzone.js 发送到不同的表单处理程序

Have dropzone.js send to different form handler on fallback

使用 Dropzone.js,是否有任何方法可以让后备表单将上传的文件发送到不同的 php 处理程序?

因此,如果用户使用完整的 Dropzone.js 界面,它会使用 "dropzone.php" 来处理文件上传,但如果用户使用旧的且不受支持的浏览器并且脚本以回退模式呈现, 然后它使用 "dropzonefallback.php" 来处理文件上传。

我尝试将 url 硬编码到似乎是 dropzone.js 中的备用表单代码中,但这不起作用:

  if (this.element.tagName !== "FORM") {
    form = Dropzone.createElement("<form action=\"dropzonefallback.php\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
    form.appendChild(fields);
  } else {
    this.element.setAttribute("enctype", "multipart/form-data");
    this.element.setAttribute("method", this.options.method);
  }

没关系,我想通了!

脚本一定在 "if" 语句的下半部分,执行以下操作就可以达到我的目的:

  if (this.element.tagName !== "FORM") {
    form = Dropzone.createElement("<form action=\"dropzonefallback.php\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
    form.appendChild(fields);
  } else {
    this.element.setAttribute("action", "dropzonefallback.php");
    this.element.setAttribute("enctype", "multipart/form-data");
    this.element.setAttribute("method", this.options.method);
  }