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
_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.
I tried your suggestion, but I get the same error...
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
I will wait for the SP.
Edgar.
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...
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..