0

I want to programmatically create a Form, and then use ajax to send the form. I have a list of MediaFile objects (videos) that I want to put in the same request. I'm following the solution posted by Raphael Schweikert Sending multipart/formdata with jQuery.ajax. This hasn't solved my problem yet, because I am not getting the files from a form. So far I have done the following:

var formData = new FormData()
// Add all the files to the formData using map function from underscore.js (same as for loop)
_.map(files, function(file, i) {
  formData.append('file-'+i, file);
});

$.ajax({
    url: 'php/upload.php',
    data: formData,
    cache: false,
    contentType: false,
    processData: false,
    type: 'POST',
    success: function(data){
        alert(data);
    }
});

The packet created has the following form:

"...\r\n[object Object].." Instead of putting the contents of the object it is putting the literal object string.

Here is a link to the MediaFile source:

https://github.com/apache/cordova-plugin-media-capture/blob/master/www/MediaFile.js

Community
  • 1
  • 1
abden003
  • 1,325
  • 7
  • 24
  • 48

0 Answers0