cubiclesoft / jquery-fancyfileuploader

A jQuery plugin to convert the HTML file input type into a fancy file uploader under a MIT or LGPL license. Mobile-friendly too!
58 stars 27 forks source link

Pass dynamic parameters #17

Closed sohanpc closed 3 years ago

sohanpc commented 3 years ago

Hi ,

I am using FancyFileUpload for file uploading. I want pass dynamic parameters. there no any option for pass dynamic parameters!!


           params : {
                action : 'create',
                id : ProdId,

                _token: $('meta[name="csrf-token"]').attr('content'),
            },
            url: '/material/colorGrid',
            edit : false,
            maxfilesize : 10000000,
            added : function(e, data) {

                var ln = $("#colorSettingModalJs .ff_fileupload_start_upload").length;

                if(ln != undefined & ln > 0){
                    $('#colorSettingModalJs .save-color').removeAttr("disabled");
                }else{
                    $('#colorSettingModalJs .save-color').attr("disabled : disabled");
                }
                // It is okay to simulate clicking the start upload button.
               // this.find('.ff_fileupload_actions button.ff_fileupload_start_upload').click();
            },
            uploadcompleted : function(e, data) {
                //l.stop();
                data.ff_info.RemoveFile();
                $('#colorSettingModalJs').modal('hide');
                colortable.ajax.reload();
                //data.ff_info.RemoveFile();
            }
        });```
cubiclesoft commented 3 years ago

You can already do that through multiple means such as data.formData (https://github.com/blueimp/jQuery-File-Upload/wiki/Options#formdata) or modifying the hidden form that can be located via data('fancy-fileupload'), which is attached to the jQuery object or using any number of jQuery File Upload passthrough options via the fileupload object during initialization. The params object is static because it is only used when creating the initial hidden form that is attached to the DOM.

By the way, CSRF/XSRF tokens should be generated for the page per user, not per request to a server. They are just there to prevent XSRF attacks. Some people go way overkill with their XSRF token strategy and create long-term headaches for both themselves and their users.

Closing this issue since this is already available via multiple means. Please keep in mind that jQuery Fancy File Uploader is a wrapper around jQuery File Upload.