GitHub user andruhon opened a pull request: https://github.com/apache/wicket/pull/255
Allow multipart submission of non modified FormData with Wicket.Ajax Wicket is currently does fancy processing of the data and it's not possible to avoid it. This commit allows to submit non processed data, which should not be processed. This change, for example, will make possible to collect files from the drag and drop event and submit these files as FormData. A drop down handler example: ```JavaScript dropArea.addEventListener("drop", dropHandler); function dropHandler(ev) { ev.preventDefault(); Wicket.Log.info("DragAndDropFileUpload drop " + dropAreaId); var dt = ev.dataTransfer; var formData = new FormData(); var files = []; var i; if (dt.items) { // DataTransferItemList for (i = 0; i < dt.items.length; i++) { if (dt.items[i].kind == "file") { var f = dt.items[i].getAsFile(); Wicket.Log.info("... file[" + i + "].name = " + f.name); files.push(f); } } } else { // DataTransfer for (i = 0; i < dt.files.length; i++) { Wicket.Log.info("... file[" + i + "].name = " + dt.files[i].name); files.push(dt.files[i]); } } if (files.length > 0) { // formData.append(attrs['f']+"_hf_0",""); files.forEach(function (f) { formData.append(fileUpload.getAttribute("name"), f) }); // Wicket.Ajax.ajax will simply submit a multipart form into the iframe, which we don't want // var xhr = new XMLHttpRequest(); // xhr.open('POST', attrs['u'] + "&wicket-ajax=true&wicket-ajax-baseurl=" + Wicket.Form.encode(Wicket.Ajax.baseUrl || '.'), true); // xhr.send(formData); // xhr.addEventListener("load", function() {console.log(arguments)}) Wicket.Ajax.ajax({ u: attrs.u, m: 'POST', mp: true, npd: formData }); } else { Wicket.Log.error("No files to upload " + dropAreaId); } } ``` You can merge this pull request into a Git repository by running: $ git pull https://github.com/andruhon/wicket master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/wicket/pull/255.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #255 ---- commit be12e65d58619cb20ccc6750fe4655de4516d642 Author: Andrew Kondratev <andruhon@...> Date: 2018-01-11T01:18:34Z Allow multipart submission of non modified FormData with Wicket.Ajax ---- ---