Remove Files with Errors

The following example demonstrates how to remove files which contain errors and which have not passed the validation by using the Kendo UI Upload.

<style>
  html {
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
  }
</style>
<input name="files" id="files" type="file" />
<script>
  function onError(e) {
    var files = e.files;
    for (var i = 0; i < files.length; i++) {
      alert("Validation failed for " + files[i].name);

      var uid = files[i].uid;
      var entry = $(".k-file[data-uid='" + uid + "']");
      if (entry.length > 0) {
        entry.remove();
      }
    }
  }

  $(document).ready(function() {
    $("#files").kendoUpload({
      async: {
        saveUrl: "save",
        removeUrl: "remove",
        autoUpload: true
      },
      error: onError
    });
  });
</script>

See Also

For more runnable examples on the Kendo UI Upload widget, browse its How To documentation folder.

In this article
Not finding the help you need? Improve this article