bernhard Posted March 1, 2016 Share Posted March 1, 2016 hi devs, i have an uikit drag&drop upload on my project and it's working fine. i have this request in my dev-tools: it sends a POST with the image data and returns a smaller version of the image (GET) in my php-code i handle it like this (some lines collapsed): can someone explain what exactly counts as $config->ajax request and what does not? thank you! Link to comment Share on other sites More sharing options...
Craig Posted March 1, 2016 Share Posted March 1, 2016 From wire/core/ProcessWire.php: $config->ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); Link to comment Share on other sites More sharing options...
Pierre-Luc Posted March 3, 2016 Share Posted March 3, 2016 According to his screenshot both requests are XHR (XMLHttpRequest), so it should be seeing them as such. I assume you're doing your call with jQuery? Do you have any proxy between the browser and the server like CloudFlare that might interfere with it? 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 3, 2016 Author Share Posted March 3, 2016 thank you pierre-luc. yes that's why i thought it should be an $config->ajax request... this is the code for the upload via uikit: /** * * stickerframeupload * */ var progressbar = $("#stickerframeprogressbar"), bar = progressbar.find('.uk-progress-bar'), settings = { action: config.pageUrl + 'setstickerframe/', // upload url single: false, // make one request per file = true/false filelimit: 1, params: {width: $('#stickerframemodal .rahmen').width()}, //allow : '*.(png)', // allow only PNG images loadstart: function() { bar.css("width", "0%").text("0%"); progressbar.removeClass("uk-hidden"); }, progress: function(percent) { percent = Math.ceil(percent); bar.css("width", percent+"%").text(percent+"%"); }, allcomplete: function(response) { bar.css("width", "100%").text("100%"); setTimeout(function(){ progressbar.addClass("uk-hidden"); }, 250); var res = JSON.parse(response); config.stickerframetmp = res.stickerframe; config.stickerframepreviewtmp = res.stickerframepreview; $('#stickerframemodal .rahmen').attr('src',res.stickerframepreview); } }; var select = UIkit.uploadSelect($("#stickerframeinput"), settings), drop = UIkit.uploadDrop($("#stickerframedrop"), settings); here is the info about uikit drag&drop upload: http://getuikit.com/docs/upload.html yes, jquery; no proxy... Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 3, 2016 Share Posted March 3, 2016 Check the xhr requests if the needed header is really present. If not it won't be recognized by processwire. Being a xhr request alone is not detectable for the webserver. 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 7, 2016 Author Share Posted March 7, 2016 thank you. seems that the headers are not set... should that be done by the uikit script? is this an issue i should report to them? Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 7, 2016 Share Posted March 7, 2016 Afaik the header is just a convention. The usage of it in libraries might vary. 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 7, 2016 Author Share Posted March 7, 2016 ok thank you for all the explanations Link to comment Share on other sites More sharing options...
Recommended Posts