Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6871 closed enhancement (worksforme)

Sending FormData with file fields set wrong content-type header

Reported by: tchak Owned by:
Priority: Milestone: 1.4.3
Component: ajax Version: 1.4.2
Keywords: FormData Cc:
Blocked by: Blocking:

Description

Sending FormData with file fields shuld result in content-type "multipart/form-data". JQuery set it to "application/x-www-form-urlencoded" which is wrong. content-type header should be left alone in such cases so xhr object will set it to a proper "multipart/form-data" + proper boundary, by him self.

FormData is experimental stuff so I dont care if it is not supported. The real problem here is ther is no way to say to jquery to not set content-type header.

I am refering to this :

if ( s.data || origSettings && origSettings.contentType ) {
  xhr.setRequestHeader("Content-Type", s.contentType);
}

As long as there is some data to send jquery will set something in Content-Type, this is good, but there should be a way to override this...

When I am talking about FormData I refere to this : FormData

Change History (2)

comment:1 Changed 9 years ago by dmethvin

Resolution: worksforme
Status: newclosed

There is a way to override it. You can pass contentType: "multipart/form-data" in the $.ajax options or put it in $.ajaxSettings so it will be used for all subsequent requests.

comment:2 Changed 9 years ago by dmethvin

I forgot to mention, please reopen with further information if I misunderstood the request.

Note: See TracTickets for help on using tickets.