jQuery file upload: Is it possible to trigger upload with a submit button?

if you have the button

<button id="up_btn">Upload</button>

You can try with

$('#fileupload').fileupload({
    dataType: 'json',
    add: function (e, data) {            
        $("#up_btn").off('click').on('click', function () {
            data.submit();
        });
    },
});

EDIT: according to comments a better answer considere off to avoid duplicated requests. (also work unbind, I do not check if is bind and unbind but jquery team recommend on and off link since 1.7)

Leave a Comment