Search code examples
javascriptjqueryfilejquery-file-uploadblueimp

Jquery File Upload invoking upload handler on load


I am using jQuery File Upload (https://github.com/blueimp/jQuery-File-Upload). I am using Terascript for my server side upload handler and it seems to work fine.

But unfortunately jQuery File Upload seems to want to invoke the upload handler on load, before you have told it what files you want to upload and manually triggered the upload. The upload handler creates an random name but of course there is no actual file associated with it.

http://dev.over60travel.com/sandbox/jquery-file-uploads/index.html

Afterwards it all seems to work fine. But why does it trigger an upload on load?


Solution

  • Thank you to Sebastian Tschan, the author of jQuery-File-Upload, for the answer to this question.

    On load the app does indeed call the upload module. I'm still not entirely sure why but the way to stop it is to comment out the follwoing lines from 'main.js'.

            // Load existing files:
    //    $('#fileupload').addClass('fileupload-processing');
    //    $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
    //        url: $('#fileupload').fileupload('option', 'url'),
    //        dataType: 'json',
    //        context: $('#fileupload')[0]
    //    }).always(function () {
    //        $(this).removeClass('fileupload-processing');
    //    }).done(function (result) {
    //        $(this).fileupload('option', 'done')
    //            .call(this, $.Event('done'), {result: result});
    //    });