Kendo Upload Control

2 posts, 0 answers
  1. Aarti
    Aarti  avatar
    20 posts
    Member since:
    Mar 2014

    Posted 19 Oct 2016 Link to this post



    I am using kendo upload control and I need to upload zip file through only if zip file has only one file inside it other wise i needed to fail the upload.  OnSuccess event of upload I am calling controller action to add validations for the upload file.  How can I send file itself through Ajax to controller action so that i can extract zip file on server side and fail the upload if zip has more than 1 file inside it.

                                  .Async(a => a.AutoUpload(false)
                                      .Save("UploadSingleDocument", "Upload")
                                  .Events(events => events



    Below is my javascript code. e.files[0] is always returning null.


                    url: ('@Url.Action("ValidateDocumentExtension", "Upload")'),
                    contentType: "application/json",
                    async: true,
                    type: "POST",
                    data: JSON.stringify({files:e.files[0], fieldlst: webFormFields, fileName: document.getElementById("DocumentName").value }),
                    success: function(data) {
                        if (data === 'False') {
                            showNotification("Upload Document", "Invalid Document Extension", "error");
                            flagUpload = false;
                        } else if (data === 'True') {
                            flagUpload = true;
                            if ($("div.k-notification-error").Exists()) {
                            if ($("div.k-notification-info").Exists()) {

  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2213 posts

    Posted 20 Oct 2016 Link to this post

    Hello Aarti,

    Generally a file cannot be uploaded through regular Ajax request. A FormData request is needed to achieve this. Nevertheless I am not sure why this is needed, since this is what the Upload widget role is - to upload the file asynchronously. You could implement the zip validation logic in the UploadSingleDocument save handler.

    Dimiter Madjarov
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top