This is a migrated thread and some comments may be shown as answers.

Error upload file also when the file is uploaded

4 Answers 2432 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Roberto
Top achievements
Rank 1
Roberto asked on 20 Sep 2012, 03:30 PM
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?

4 Answers, 1 is accepted

Sort by
0
Eliezer
Top achievements
Rank 1
answered on 12 Jan 2013, 03:33 PM
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.



0
Daniel
Telerik team
answered on 17 Jan 2013, 07:51 AM
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!
0
Tayger
Top achievements
Rank 1
Iron
answered on 13 Apr 2017, 08:08 PM

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);
...
?>

 

0
Dimiter Madjarov
Telerik team
answered on 14 Apr 2017, 11:39 AM

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.
Tags
Upload
Asked by
Roberto
Top achievements
Rank 1
Answers by
Eliezer
Top achievements
Rank 1
Daniel
Telerik team
Tayger
Top achievements
Rank 1
Iron
Dimiter Madjarov
Telerik team
Share this question
or