Bootstrap File Input Demo

Thankful to Krajee!
to get more out of us.

You can carry out validations OR get confirmations from user before upload. This example uses the filebatchpreupload event to trigger a confirmation dialog. It then uses the event manipulation documentation feature of the plugin to trigger an abort message based on confirmation dialog. You can read in additional data through the events as shown in the example below. For this example, the user is alerted to confirm if the number of files for upload is OK and proceed else an upload abort message is shown.


Code

<div class="file-loading">
    <input id="input-708" name="kartik-input-708[]" type="file" multiple>
</div>

<script>
$(document).on("ready", function() {
    $("#input-708").fileinput({
        uploadUrl: "/file-upload-batch/1",
        uploadAsync: false,
        maxFileCount: 5
    }).on('filebatchpreupload', function(event, data) {
        var n = data.files.length, files = n > 1 ? n + ' files' : 'one file';
        if (!window.confirm("Are you sure you want to upload " + files + "?")) {
            return {
                message: "Upload aborted!", // upload error message
                data:{} // any other data to send that can be referred in `filecustomerror`
            };
        }
    });
});
</script>

Note

You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.

The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.