Error handling for the failed files

3 posts, 0 answers
  1. JoJo
    JoJo avatar
    20 posts
    Member since:
    Dec 2012

    Posted 03 Jan 2013 Link to this post

    Hi Team, 

    I am using Kendo UI file upload control with multiple attribute set to true.

    Does File Upload control handles the failed uploads on its own ?

    I am using the following code snippet on the server and i am posting data through web api.

    [HttpPost]
            public Task Post()
            {
                var folderName = "Uploads";
                //var PATH = HttpContext.Current.Server.MapPath("~/" + folderName);
                var PATH = "C://Uploads/";
                var rootUrl = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);
                if (Request.Content.IsMimeMultipartContent())
                {
                    var streamProvider = new MultipartFormDataStreamProvider(PATH);
                    var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith(t =>
                    {
                        if (t.IsFaulted || t.IsCanceled)
                        {
                            throw new HttpResponseException(HttpStatusCode.InternalServerError);
                        }                    
                    });
                    return task;
                }
                else
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
                }
            }

     I want to capture the error information for the failed files and display that information to the user.

    Kendo file upload is just returning the status as Failed for the failed uploads but how we can pass the actual error information back to the user?

    Thanks
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Jan 2013 Link to this post

    Hello,

     You can try using the error event for that. The event arguments contain XMLHttpObject which you can then use to get the responseText.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Zachary
    Zachary avatar
    23 posts
    Member since:
    Feb 2013

    Posted 04 Dec 2013 Link to this post

    I was able to make use of XMLHttpRequest with the following code:

    $("#upload").kendoUpload({
        async: {
            saveUrl: "save",
            removeUrl: "remove",
            autoUpload: true
        },
        error: function (e) {
            var err = $.parseJSON(e.XMLHttpRequest.responseText);
     
            alert(err.Message);
     
            $.map(e.files, function (file) {
                alert("Could not upload " + file.name);
            });
        }
    });

Back to Top