Skip to content

2.4.5

Compare
Choose a tag to compare
@m-mujica m-mujica released this 01 Oct 17:56
· 12 commits to master since this release

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");
  }
});