1.ajaxfileupload上传的时候出现错误,无法获取错误信息,需要在ajaxfileupload.js的源码中加入以下代码
handleError: function (s, xhr, status, e) { // If a local callback was specified, fire it if (s.error) { s.error.call(s.context || s, xhr, status, e); } // Fire the global callback if (s.global) { (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e]); } },
插入代码的位置为
2.ajaxfileupload在上传的时候如果需要进行传递参数的时候,需要在ajaxfileupload.js的源码中修改以下代码,改动如图中标注位置
3.当使用ajaxfileupload进行二级域名跨域上传的时候,需要修改的内容为
(1) 调用上传的html页面所在域名是 www.abc.com ,添加document.domain
<script>
document.domain = "abc.com";
</script>
(2)上传的服务端也需要进行document.domain注明
public
ActionResult Upload()
{
string
message =
"上传成功,文件大小:"
+ size;
json =
new
JsonResult
{
Data =
new
{
success =
true
,
message = message,
data =
new
{
name = name,
upload_name = upload_name,
extension = extension,
size = size,
url = url,
download_url = file_downloadpath + url
}
}
};
return
CrossDomainContent(json);
}
private
ContentResult CrossDomainContent(JsonResult json)
{
StringBuilder sb =
new
StringBuilder();
sb.Append(
"<script> document.domain = 'abc.com'; </script>"
);
sb.Append(JsonConvert.SerializeObject(json.Data));
return
Content(sb.ToString());
}