如何获取队列中的文件大小总数。我想允许用户只上传 100 mb 文件,所以现在如果有人选择大于 100 mb 的文件,此代码效果很好,但当我选择 2 个 60-60 mb 的文件时,总大小为 120 mb,这不会显示任何错误。任何相同的想法
$(function() {
$("#uploader").plupload({
runtimes : 'html5,flash,silverlight',
url : 'http://<?=$bucket?>.s3.amazonaws.com/',
multipart: true,
multipart_params: {
'key': '<?=$filepath?>${filename}', // use filename as a key
'Filename': '${filename}', // adding this to keep consistency across the runtimes
'acl': 'public-read',
'Content-Type': 'application/octet-stream',
'AWSAccessKeyId' : '<?=$accessKeyId?>',
'policy': '<?=$policy?>',
'signature': '<?=$signature?>'
},
// optional, but better be specified directly
file_data_name: 'file',
filters : {
// Maximum file size
max_file_size : '100mb'
// Specify what files to browse for
//mime_types: [
// {title : "Image files", extensions : "jpg,jpeg"}
//]
},
// Flash settings
flash_swf_url : 'js/Moxie.swf',
// Silverlight settings
silverlight_xap_url : 'js/Moxie.xap'
});
});
最佳答案
试试这个:
/* Check the queue after files added to see if the total size of all files combined exceeds allowed limit. */
var maxQueueSize = 681574400; // Size in bytes. This is set to 650MB.
uploader.bind('QueueChanged', function(up) {
if(uploader.total.size > maxQueueSize) {
alert("Total size of all files exceeds disc capacity! Remove some files!");
}
});
关于javascript - 如何在plupload中获取队列的总文件大小而不是单个文件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34604780/