Silverstripe Version: 4.7
Question:
I’ve been trying to do an ajax file upload using FormData in javascript, but I’m getting nothing on the server side.
The form is just a bunch of TextFields & an UploadField.
This is the JS method:
saveForm(e) {
e.preventDefault();
const url = '/location-edit/save';
const form = e.target;
if(!form.reportValidity()) {
return;
}
const data = new FormData(form);
return fetch(url, {
method: 'POST',
body: data
})
.then(response => response.text())
.then(data => {
console.log(data);
})
}
What do I need to do on the server side to receive the file upload data? I’m stumped and there is very little information online.
Thanks