how to add files added to the dropzone and send them in an ajax request as if they were input file fields

71 Views Asked by At

I want to receive the files in a formData and send in an ajax request and I want the server to receive it as if it were an input file field.

I tried this: Add files from Dropzone to form

but when I make the request, my server doesn't recognize it as an input file field

$.ajax({
        url: args.url,
        data: formData, /*I want the file inside this formData */
        success: function(data){
            
        }, error: function() {

        }
    });
1

There are 1 best solutions below

0
On

You can try to add processData : false and contentType : false to your ajax

As below:

$.ajax({
        url: args.url,
        data: formData, /*I want the file inside this formData */
        processData : false,
        contentType : false,
        success: function(data){
            
        }, error: function() {

        }
});