使用h5+上传文件,监听上传进度的时候,永远就是 0% 然后100%
实际文件还远远没有上传完成.
task.addData("client", "HelloH5+");
task.addData("uid", getUid());
task.addEventListener("statechanged", onStateChanged, true);
for(var i = 0; i < files.length; i++) {
var f = files[i];
task.addFile(f.path, {
key: f.name
});
}
task.start();
function onStateChanged(upload, status) {
console.log(JSON.stringify(upload));
console.log(JSON.stringify(status));
if(upload.state == 3) {
var percent = Math.ceil(upload.uploadedSize/upload.totalSize*100);
outLine("Uploading: " + percent + "%");
}
}