kartik-v / bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
http://plugins.krajee.com/file-input
Other
5.36k stars 2.39k forks source link

Issue with uploadExtraData property in 4.2.4 version - POST is not including the parameters in the body #370

Closed rogelio-blanco closed 9 years ago

rogelio-blanco commented 9 years ago

Hi Kartik,

I update bootstrap-fileinput to the latest and I having issues sending the extraData when I would like to upload the image. For some reason after I update the extra data is not been sent. Could you please take a look of the code?

    /* File upload ajax */
    $("#inputImageUpload").fileinput({
        language: "es",
        elErrorContainer: "#imageUploadErrorBlock",
        showRemove: false,
        showUpload: false,
        maxFileCount: 1,
        maxFileSize: 5120,
        previewFileType: "image",
        allowedFileExtensions: ["jpg", "jpge", "png", "gif"],
        uploadUrl: baseUrl + "images",
        ajaxSettings: {
            beforeSend: function( xhr ) {
                xhr.setRequestHeader('X-CSRF-Token', 'Token");
            } 
        },
        uploadAsync: false,
        uploadExtraData: function() {
            return {
                name: "dummy",
                folder: "dummyFolder"
            };
        }
    });
rogelio-blanco commented 9 years ago

After go back to 4.2.1 the same code is working. Seems to me that maybe in 4.2.4 sending body parameters work different or its a bug.

If the functionality change please let me know how should I change my code.

kartik-v commented 9 years ago

With v4.2.4 uploadExtraData is parsed in ajax beforeSend as per issue #342. Can you check if you are receiving it fine on your server code.

kartik-v commented 9 years ago

I will check if there is a better way to fix that.

rogelio-blanco commented 9 years ago

I check the request and I don't see the parameters in the body. I also try to add "data" attribute inside of "ajaxSettings", that way I was able to see it on the request but the server was not able to parse it.

Let me know if you would like to see some request samples with both versions.

rogelio-blanco commented 9 years ago

Work as a charm (4.2.5). Thanks