gpt4 book ai didi

javascript - Plupload uploadprogress 事件总是给 file.percent 作为 100

转载 作者:可可西里 更新时间:2023-11-01 02:12:39 27 4
gpt4 key购买 nike

我正在使用从 http://www.plupload.com 下载的 plupload.full.js用于上传图片。

我的问题是,当我尝试使用上传进度事件显示进度条时,它始终只给出值 100。这是一个问题吗?我该如何解决这个问题?
在此先感谢您的帮助。

最佳答案

尝试上传大图片文件看截图

enter image description here

var uploader = new plupload.Uploader({
runtimes : 'html5,flash,silverlight,html4',

browse_button : 'pickfiles', // you can pass in id...
container: document.getElementById('container'), // ... or DOM Element itself

url : "https://github.com/moxiecode/plupload/blob/master/examples/upload",

filters : {
max_file_size : '10mb',
mime_types: [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
]
},

// Flash settings
flash_swf_url : 'https://cdnjs.cloudflare.com/ajax/libs/plupload/2.3.6/Moxie.swf',

// Silverlight settings
silverlight_xap_url : '/plupload/js/Moxie.xap',


init: {
PostInit: function() {
document.getElementById('filelist').innerHTML = '';

document.getElementById('uploadfiles').onclick = function() {
uploader.start();
return false;
};
},

FilesAdded: function(up, files) {
plupload.each(files, function(file) {
document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
});
},

UploadProgress: function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
},

Error: function(up, err) {
document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
}
}
});

uploader.init();
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/plupload/2.3.6/plupload.full.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/plupload/2.3.6/moxie.js"></script>

<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<br />

<div id="container">
<a id="pickfiles" href="javascript:;">[Select files]</a>
<a id="uploadfiles" href="javascript:;">[Upload files]</a>
</div>

<br />
<pre id="console"></pre>


<script type="text/javascript">
// Custom example logic


</script>

关于javascript - Plupload uploadprogress 事件总是给 file.percent 作为 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16463886/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com