Bug Tracker

Modify

Ticket #6871 (closed enhancement: worksforme)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to worksforme

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 3 years ago by dmethvin

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.