0

This plugin is working well for form submission, except for uploading files. Looking in the code, I descovered that posting inputs is made possible when defining the request variable by : data:$form.serialize(). The documentation for (serialize) states : 'Data from file select elements is not serialized'.

So question : is there someone who made an addition supporting file uploads. I have already started thinking to add a function myself, unless there is already some solution out there.

user2992220
  • 1,092
  • 1
  • 12
  • 20

1 Answers1

0

Meanwhile I figured out a solution to support file upload:

if(typeof FormData === 'function'){
    // file upload supported
    var request = {
        url: $form.prop('action'),
        data: new FormData($form[0]),
        type: $form.prop('method'),
        async: false,
        cache: false,
        contentType: false,
        enctype: 'multipart/form-data',
        processData: false
    };
}else{
    // file upload not supported
    var request = {
        url: $form.prop('action'),
        data: $form.serialize(),
        type: $form.prop('method')
    };
}
user2992220
  • 1,092
  • 1
  • 12
  • 20