php不解析ajax发送的multipart / form-data表单数据中的数据

我在html中有这个表单,它同时包含文件和其他输入元素:

ABOVE UNDER POSITIVE NEGATIVE ++

这是我用于通过ajax提交表单数据的javascript / jquery代码:

 $('form[data-async]').on('submit', '', function(event) { //form data object event.preventDefault(); var $form = $(this); var __fd = new FormData($form[0]); $.ajax({ type: $form.attr('method'), url: $form.attr('action'), data: __fd, processData: false, beforeSend: function(xhr) { //not important }, success: function(data, status) { data = $.parseJSON(data); if (data.success) { //not important } else { //not important } }, error: function() { //not important } }); return false; }); 

提交数据后,在表单的目标URL上执行var_dump($_POST) ,将获得以下信息:

  array(2) { ["_url"]=> string(12) "/disease/add" ["------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition:_form-data;_name"]=> string(1404) ""name" asdasdaasdasdasdasda ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="description" asdsad ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="category[]" 5 ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="category[]" 4 ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="category[]" 1 ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="category[]" 7 ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="approach"; filename="" Content-Type: application/octet-stream ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="symptom[0][is_patogonomic]" on ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="symptom[0][name]" asdasd ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="symptom[1][is_patogonomic]" on ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="symptom[1][name]" asdasd ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="lab_symptom[0][name]" asdasdasd ------WebKitFormBoundaryHmT1pwGJDYbVxvrN Content-Disposition: form-data; name="lab_symptom[0][anomaly_type]" ABOVE ------WebKitFormBoundaryHmT1pwGJDYbVxvrN-- " } 

好像php不解析这些数据而$ _POST数组只有两个成员。 谁能告诉我我做错了什么?

谢谢

尝试添加contentType: false

 $.ajax({ type: $form.attr('method'), url: $form.attr('action'), data: __fd, processData: false, contentType: false , // tell jQuery not to set contentType beforeSend: function(xhr) { //not important }, success: function(data, status) { data = $.parseJSON(data); if (data.success) { //not important } else { //not important } }, error: function() { //not important } 

});