我在适用于 ios6 的 Google Chrome 上的 xmlhttprequest 文件上传进度事件有问题。代码已经在所有桌面浏览器和 Safari(ios 6) 上运行。在谷歌浏览器(ios 6)中上传mov文件也存在问题,尝试上传时我得到文件大小= 0。有什么解决方案吗?
这是我的代码的一部分
var xhr = new XMLHttpRequest();
var eventSource = xhr.upload;
xhr.addEventListener("load", this.onUploadComplete(uploadInfo));
xhr.addEventListener("error", this.onUploadError(uploadInfo));
xhr.addEventListener("abort", this.onUploadAbort(uploadInfo));
// changing Url for preventing ajax call caching( Android , IOS 6)
var ts = Date.now(), rquery = /\?/, rts = /([?&])_=[^&]*/,
ret = uploadUrl.replace( rts, "$1_=" + ts );
uploadUrl = ret + ( ( ret === uploadUrl ) ? ( rquery.test( uploadUrl ) ? "&" : "?" ) + "_=" + ts : "" );
xhr.open('POST', uploadUrl, true);
eventSource.onprogress = this.onUploadProgress(uploadInfo);
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.setRequestHeader('X-FILE-NAME', file.name);
xhr.send(file);