How can I process an XHR POST request in a Kirby 2 plugin in my route?
I see the request header and the data the browser, and the response (is always fine 200 ok), but nothing happens on the server side.
I’m using an API here - more specifically, it’s about filepond.
The boilerplate of the filepond runs without any problems, but in Kirby I do not get the curve - wie man in englisch so schön sagt Does anyone have an idea? - Mercy.
kirby()->routes(
array(
array(
'pattern' => 'student/abhakliste/filepond',
'method' => 'POST',
'action' => function () {
include (__DIR__.DS.'filepond-api'.DS.'submit.php');
// TODO den Rest müsste die API machen...
},
), ...
The upload consists of two parts, first an XHR request, with which the files are loaded onto the server when dropped in filepond and stored in a temporary directory. Then second a normal Form Post via submit button that would probably work, because the above route is called, and fails because in the first step, nothing was loaded into the temporary directory.
(Ps. My plan is to do step two also via XHR Request, to get rid of the submit button)
I have added the Server Options… process and revert…
The “process” path changed the behavior slightly - there is now an additional XHR Request which contains the image data… but the temp files are also not created…
By The way: all upload folders are in place with chmod 777.
FilePond.setOptions({
// maximum allowed file size
maxFileSize: '5MB',
// crop the image to a 1:1 ratio
imageCropAspectRatio: '1:1',
// resize the image
imageResizeTargetWidth: 300,
// upload to this server end point
server: {
url:'https://devfak.carsten-nichte.de/student/abhakliste/filepond',
process: '/process',
fetch: null,
revert:'/revert'
}
});