我使用 XMLHttpRequest 发送文件,它工作正常,但文件大小小于 130 kB。
我的代码是
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = function(e){
if (e.lengthComputable){
self._loaded[id] = e.loaded;
self._options.onProgress(id, name, e.loaded, e.total);
}
};
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
self._onComplete(id, xhr);
}
};
// build query string
params = params || {};
params['qqfile'] = name;
var queryString = qq.obj2url(params, this._options.action);
xhr.open("POST", queryString, true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.send(file);
有人可以帮我吗?
最佳答案
禁用 mod_security(PHP 服务器)后问题已解决。
关于javascript - XMLHttpRequest 仅发送最大大小为 130 kB 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16141222/