Uploadifive dynamically posting input variables

前端 未结 2 1602
灰色年华
灰色年华 2021-01-06 03:52

The problem below is that when the function is initiated, of course, MyInputVariable is empty.


$(function ()          


        
2条回答
  •  清酒与你
    2021-01-06 04:29

    I think this is best anwser

    How to submit dynamic variables with uploadifive

    replace this:

    'formData': {
            'timestamp': '',
            'token': '',
            'MyNumber': $('#MyInputVariable').val(),
        },
    

    by this:

    'onUpload' : function(){
    $('#file_upload').data('uploadifive').settings.formData = {
            'timestamp': '',
            'token': '',
            'MyNumber': $('#MyInputVariable').val(),
    }},
    

    and this is full code:

    
    $(function () {
        $('#file_upload').uploadifive({
            'auto': false,
            'dnd': true,
            'checkScript': 'check-exists.php',
            'onUpload' : function(){
                    $('#file_upload').data('uploadifive').settings.formData = {
                            'timestamp': '',
                            'token': '',
                            'MyNumber': $('#MyInputVariable').val(),
                                }},
            'queueID': 'queue',
            'uploadScript': 'upload.php',
            'onUploadComplete': function(file, data) {console.log(data);}
        });
    });
    

提交回复
热议问题