Javascript Events

The file upload widget emits two custom events - when an upload starts and when a file has uploaded successfully.

  1. The event fileUploadStarted is emitted when the user starts an upload.
  2. The event fileUploadSuccess is emitted when the file has uploaded successfully.

An example of how to listen to these event is shared below:

Give the form element a custom id:

<input type="hidden" id="test-files-uploader" class="simple-file-upload">

Grab the id of the form input:

  const el = document.getElementById("test-files-uploader");

To listen to the file upload started event:

   el.addEventListener("fileUploadStarted", function (e) {
    alert('file upload started' + this.value)

To listen to the file upload success event:

  el.addEventListener("fileUploadSuccess", function (e) {