Skip to main content

Bug Tracker

Side navigation

#6871 closed enhancement (worksforme)

Opened August 04, 2010 04:19PM UTC

Closed August 05, 2010 12:12AM UTC

Last modified August 05, 2010 12:13AM UTC

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

Attachments (0)
Change History (2)

Changed August 05, 2010 12:12AM UTC by dmethvin comment:1

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.

Changed August 05, 2010 12:13AM UTC by dmethvin comment:2

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