Created
December 4, 2012 09:26
-
-
Save nicoolas25/4202155 to your computer and use it in GitHub Desktop.
Patch to make dragonfly happy with fineuploader 3.0. (for 3.1 see the paramsInRequestBody option)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- fineuploader-3.0.js 2012-11-16 21:30:02.000000000 +0100 | |
+++ fineuploader-3.0.patched.js 2012-12-04 10:21:56.799781578 +0100 | |
@@ -1796,7 +1796,15 @@ | |
var protocol = this._options.demoMode ? "GET" : "POST" | |
var form = qq.toElement('<form method="' + protocol + '" enctype="multipart/form-data"></form>'); | |
- var queryString = qq.obj2url(params, this._options.endpoint); | |
+ // Params arn't given through form's action anymore but appened into it. | |
+ var queryString = qq.obj2url({}, this._options.endpoint); | |
+ for (paramName in params) { | |
+ var paramInput = document.createElement("input"); | |
+ paramInput.setAttribute('type', 'text') | |
+ paramInput.setAttribute('name', paramName) | |
+ paramInput.setAttribute('value', params[paramName]) | |
+ form.appendChild(paramInput); | |
+ } | |
form.setAttribute('action', queryString); | |
form.setAttribute('target', iframe.name); | |
@@ -1904,7 +1912,13 @@ | |
// build query string | |
params = params || {}; | |
params[this._options.inputName] = name; | |
- var queryString = qq.obj2url(params, this._options.endpoint); | |
+ | |
+ var queryString; | |
+ if (this._options.forceMultipart) { | |
+ queryString = qq.obj2url({}, this._options.endpoint); | |
+ } else { | |
+ queryString = qq.obj2url(params, this._options.endpoint); | |
+ } | |
var protocol = this._options.demoMode ? "GET" : "POST"; | |
xhr.open(protocol, queryString, true); | |
@@ -1913,6 +1927,7 @@ | |
xhr.setRequestHeader("Cache-Control", "no-cache"); | |
if (this._options.forceMultipart) { | |
var formData = new FormData(); | |
+ for (paramName in params) formData.append(paramName, params[paramName]); | |
formData.append(this._options.inputName, file); | |
file = formData; | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment