Error upload file also when the file is uploaded

5 posts, 0 answers
  1. Roberto
    Roberto avatar
    1 posts
    Member since:
    Mar 2012

    Posted 20 Sep 2012 Link to this post

    Hi all, I'm using the kendoUpload module on my ruby on rails application, everythings is except for the fact that kendoUpload fires an error event even if the file is correctly uploaded.

    My javascript code is this:

    function onError(e) {
       console.log("Error (" + e.operation + ") :: " + getFileInfo(e));
     }
     
    $("#media_filename").kendoUpload({
            async: {
                saveUrl: '/admin/media/',
                removeUrl: '/admin/media/remove',
                autoUpload: true
            },
            multiple: true,
            upload: onUpload,
            success: onSuccess,
            error: onError,
            complete: onComplete
        });

    the code from my controller gives me back a 200 ok http header (I see with on firebug), but (as you can se from the attach) the kendoUpload components tell's me that the file isn't uploaded but it is not true.

    Any hint? Do you need more information?
  2. Eliezer
    Eliezer avatar
    3 posts
    Member since:
    Dec 2012

    Posted 12 Jan 2013 Link to this post

    I'm with the same problem. Look my screen shot attached. You can see that server answered with status 200 but kendo upload throw onError event. When I went to the server upload directory the file was there.



  3. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 17 Jan 2013 Link to this post

    Hi,

    The server handler should return either an empty result or JSON to signify success like described in this documentation topic. Anything else is considered as failure and the error event will be triggered.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Tayger
    Tayger avatar
    191 posts
    Member since:
    Jan 2015

    Posted 13 Apr 2017 in reply to Daniel Link to this post

    Hi 

    I was running into the same problem: The server return message stated everything is fine but ran into error event on upload just because I returned something. Well it works as designed but I don't understand why KendUi (error event) in this case only reacts on the server status, independent what was sent back from server as text in whatever format. 

    The main reason of my post is to make someones life easier: As the documentation says: text/plain and JSON. If you  are using PHP serverside you can do that with:

    <?php
    header("Content-type: text/plain");
    ...
    echo json_encode($yourObject);
    ...
    ?>

     

  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 14 Apr 2017 Link to this post

    Hello Tayger,

    You are correct, returning a "text/plain" JSON is the correct way to send back data from the server to the Upload. This will trigger the success event, which is preventable:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/upload#events-success

    This way you could still mark a file as unsuccessfully uploaded, depending on the data returned.

    Regards,
    Dimiter Madjarov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top