我们如何将自定义错误消息传递给uploadify?
如果在控制器动作上,有一个异常(由 try/catch 捕获)——我们如何将它传递给 uploadify 脚本?永远不会调用 onError 事件?
[HttpPost]
public ActionResult Upload(HttpPostedFileBase fileData, FormCollection forms)
{
try
{
if (fileData.ContentLength > 0)
{
var statusCode = Helper.UploadList();
if (statusCode.Equals(System.Net.HttpStatusCode.Created))
return Json(new { success = true });
}
}
return Json(new { success = false });
}
catch (Exception ex)
{
return Json(new { success = false });
}
}
'onComplete': function (event, queueID, fileObj, response, data) {
if (response == '{"success":true}') {
alert("File uploaded successfully.");
}
else if (response == '{"success":false}') {
alert('File failed to upload. Please try again!');
}
else {
$("#file_uploadDomain").uploadifyCancel(queueID);
}
return false;
},
'onError': function(event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
},