如何获取队列中的文件总大小。我想允许用户只上传100 MB的文件,所以现在如果任何人选择一个大于100mb的文件,这个代码工作正常,但是当我选择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'
});
});
答案 0 :(得分:1)
试试这个:
/* 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!");
}
});