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

Two problems with uploader

6 Answers 247 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Edgar Paulk
Top achievements
Rank 1
Edgar Paulk asked on 09 Apr 2011, 12:28 AM
Hi Guys:

I have two problems with the uploader control:

Error #1:

If I load two images (one after the other, no by selecting 2 at the same time) I get this error:

"Error! Remove operation failed. Unexpected response - see console."


Problem/Error #2:


In my upload process, I save the file information on a database table, and then I rename the file to a GUID.

For this reason, my action “save” returns a GUID.

In the latest firefox, chrome and safari, works perfect. However, in IE 9 I get this estrange dialog, offering save a file.


I attached a project replicating the errors; and a screen captures of the errors dialogs.

Thanks!

Edgar.

6 Answers, 1 is accepted

Sort by
0
Andreas Botsikas
Top achievements
Rank 2
answered on 10 Apr 2011, 04:46 PM
I had the same problem. I was uploading an image using a single file uploader and then if I tried to upload another one, the remove ajax call would fail without any error. Searching around the net I found out that I had to modify the ajax call to explicitly set the contentType to "application/json;charset=utf-8". In order to make this happen, I edited the telerik.upload.min.js file and changed the _submitRemove function to the following:

_submitRemove:

 

function(w,u,x){var v={};v.fileNames=w;n.ajax({type:"POST",contentType:"application/json;charset=utf-8",url:this.async.removeUrl,traditional:true,data:''

,success:u,error:x})}

hope this helps!

 

PS: Note that in my case I don't want to do something in the web server when the user removes a file. This is why I have also removed the data send on each request(to minimize the request's lenght since I am working over gprs). If you want to keep the original functionality, then you should only try to add the contentType option.

0
Edgar Paulk
Top achievements
Rank 1
answered on 11 Apr 2011, 04:29 AM
Thanks!

I tried your suggestion, but I get the same error...
0
Accepted
T. Tsonev
Telerik team
answered on 11 Apr 2011, 12:21 PM
Hi Edgar,

Thank you for submitting a sample project.

The first issue is a result of a bug. The upload tries to call the Remove action, but it fails because it's not configured. We've fixed it and the fix will be available in the Service Pack that is due this week. For the moment you can configure an empty Remove method as a workaround.

The second issue is a known limitation of the Upload. The response must be returned as text/plain even if it is JSON:
return Json(newGuid, "text/plain");

It needs this exactly in order to avoid the "Save As" dialog in IE and FF 3.x

As a token of gratitude for your involvement your Telerik points have been updated.

Best regards,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Edgar Paulk
Top achievements
Rank 1
answered on 11 Apr 2011, 06:22 PM
Thanks!

I will wait for the SP.

Edgar.
0
simone
Top achievements
Rank 1
answered on 27 Apr 2011, 03:26 PM
Hi, I've tried what you suggest (a fake remove) but I receive the same error...

this is my fake remove:

public ActionResult _FakeRemove(string[] fileNames) {
      return Json(new { status = "OK", remove = "Removed" }, "text/plain");
}

and then on client side I have:

function onUploadSuccess(e) {
    if (e.response.error) {
        alert(e.response.error);
    } else if (e.response.remove) {
 
    } else if (e.response) {
        $('#RulsetTestResult').html($.dump(e.response));
    }
     
}

here how I use Upload:

@(Html.Telerik()
            .Upload()
            .Name("RulsetTestFile")
            .Multiple(false)
            .Async(config => {
                config.AutoUpload(true);
                config.Save("_PerformRulesetTest", "Grids", new { GridId = ViewBag.GridId });
                config.Remove("_FakeRemove", "Grids");
            })
            .ShowFileList(true)
            .Localizable("it-IT")
            .ClientEvents(events => events
                    .OnSuccess("onUploadSuccess")
                    .OnError("onUploadError"))
         )

and I receive the error "Expected ;" both when selecting a new file or clicking on "remove" button...
0
jinal
Top achievements
Rank 1
answered on 01 Oct 2011, 04:04 AM
I also get same error while working with Telerik Upload for MVC.

When i checked error in detail it has error related to parseError. As per my knowledge previously when i used JQuery 1.4.2 this issue is not there but i updated to Jquery 1.5.1 and i get this error.

I did following thing and it resolved issue and i hope it helpful to other people to.

I update telerik.upload.min.js

n.ajax({type:"POST",dataType:"json",url:this.async.removeUrl ...

In this i replace dataType with "text" and it seems working for me.

Please provide your suggestion too..
Tags
Upload
Asked by
Edgar Paulk
Top achievements
Rank 1
Answers by
Andreas Botsikas
Top achievements
Rank 2
Edgar Paulk
Top achievements
Rank 1
T. Tsonev
Telerik team
simone
Top achievements
Rank 1
jinal
Top achievements
Rank 1
Share this question
or