2.4.5
Fix issue with multipart/form-data uploads
This patch release fixes an issue where can-ajax sets the incorrect Content-Type header when the request payload is a FormData instance.
For file uploads or where manually using FormData in the can-ajax request payload, DO NOT SET the Content-Type header to multipart/form-data. The browser will set the correct header and boundary.
Do this:
ajax({
url: "....",
type: "POST",
data: formData
});Instead of this:
ajax({
url: "...",
type: "POST",
data: formData,
beforeSend(xhr) {
xhr.setRequestHeader("Content-Type", "multipart/form-data");
}
});