2015-02-24 52 views
0

使用Dropzone.js,有沒有辦法讓後備表單發送上傳的文件到不同的PHP處理程序?Dropzone.js發送到不同的表單處理程序在後備

因此,如果用戶使用完整的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); 
    } 

回答

1

沒關係,我想通了!

腳本必須已在「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); 
    } 
相關問題