New to Kendo UI for jQuery? Download free 30-day trial

Remove Files in the Upload with Confirmation Dialog

Environment

Product Progress Kendo UI Upload for jQuery
Operating System Windows 10 64bit
Visual Studio version Visual Studio 2017
Preferred Language JavaScript

Description

How can I remove files in the Kendo UI Upload by displaying a custom confirmation dialog?

Solution

The following example demonstrates how to display a custom confirmation dialog by utilizing the kendo.confirm() method.

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

    <script>
      $(document).ready(function() {
         var fileUidToRemove = "";

          $("#files").kendoUpload({
            async: {
              autoUpload: false,
              saveUrl: "save",
              removeUrl: "remove",
              withCredentials: false
            },
            remove: function(e) {
              fileUidToRemove = e.files[0].uid;
              e.preventDefault();

              kendo.confirm("Remove the file?").then(function(){
                $("#files").data("kendoUpload").removeFileByUid(fileUidToRemove);
              });
            }
          });
      });
    </script>

See Also

In this article