select

Fired when one or more files have been selected using the file browse dialog, right before they are added to the list of upload files.

The event object receives the following additional properties:

  • files - a list of File objects in the current selection operation. Each file contains:
    • name - the name of the file
    • size - the size of the file in bytes
    • type - the file's MIME type

This event can be cancelled.

<input type="file" name="files" id="files" />

<script type="text/javascript">
    jQuery(function ($) {
        $('#files').shieldUpload({
            events: {
                select: function(e) {
                    for (var i=0; i<e.files.length; i++) {
                        if (/\.php$/i.test(files[i].name)) {
                            // cancel the event if any bad files found
                            e.preventDefault();
                            break;
                        }
                    }
                }
            }
        });
    });
</script>