Blueimp jQuery-File-Upload Reset Options Runtime

79 Views Asked by At

I'm using https://github.com/blueimp/jQuery-File-Upload but can't work out if I can update the objects options once set. I instantiate the uploader like this

var uploadOBJ = $('#fileupload').fileupload({
        singleFileUploads: false,
        multipart: true,
        maxNumberOfFiles: 2,
        sequentialUploads: true
        })

I need to change the singleFileUploads, maxNumberOfFiles & sequentialUploads properties after this base instantiation based on a users choice.

I have a drop down list that lets users choose between uploading a file pair or lots of individual files. The default is a file pair so I want the settings as above, then both files will be sent in the same request to a max of 2 files in the upload. If the user picks to upload loads of files I want to change the singleFileUploads to true, maxNumberOfFiles to another number I can control/set and sequentialUploads to false at runtime, this will change the uploaders behavior and force each file into individual request uploads. I can't find a way to reset these basic options without reloading the page.

1

There are 1 best solutions below

0
Diplonics On

I should read the manual more closely: https://github.com/blueimp/jQuery-File-Upload/wiki/API

Can now run this code from the dropdown's onchange event and seems to be working as needed.

$('#fileupload').fileupload(
    'option',
    {
        'singleFileUploads': true,
        'sequentialUploads': true
    }
);