0

I am using html5 to allow allow drag and drop of files , and submit form data along with files in a multipart/form-data request with the mozilla FormData() api ( there is a append() function for a FormData object and I append values and files with it ). I use the jQuery.ajax() and set the data to the FormData object I created and set the processData flag to false, and contentType to "multipart/form-data" , with a beforeSend handler call jqXHR.setReqeustHeader("Conetent-Type", "multipart/form-data") again . But in the firebug I can see that request header is still having Content-Type: text/html .

It seems $.ajax() ignore my content type specification . Has anyone else successfually using jQuery.ajax() to work with FormData api of html5 ?

I know that I can make my own XMLHttpReqeust without help of jquery , and it works too . But I like a unified framework such as jquery.

3
  • You can set contentType: 'multipart/form-data' with jQuery, IIRC. Commented Dec 8, 2011 at 4:38
  • I did both the contentType: "multipart/form-data" , and the beforeSend event where I call jgXHR.setRequestHeader("Content-Type", "multipart/form-data") . Commented Dec 8, 2011 at 5:03
  • I found another post that solves the problem . stackoverflow.com/questions/5392344/… Commented Dec 9, 2011 at 5:39

1 Answer 1

1

You should set contentType to false instead of real content type. Also set processData to false. Here is more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.