【发布时间】:2023-03-21 19:33:02
【问题描述】:
我使用插件 jQuery-File-Upload。 如何限制从本地机器选择文件的数量?
【问题讨论】:
标签: javascript jquery file-upload jquery-file-upload
我使用插件 jQuery-File-Upload。 如何限制从本地机器选择文件的数量?
【问题讨论】:
标签: javascript jquery file-upload jquery-file-upload
您可以通过在输入元素中添加 onchange 事件来限制提交前的文件数量。一旦它被触发,您就会检查文件的数量。以下是 2 个文件限制的简单示例:
<input type="file" onchange="if(parseInt($(this).get(0).files.length)>2)
alert('You can only upload a maximum of 2 files');
else alert('You are within the limit');" multiple/>
【讨论】:
使用maxNumberOfFiles
$('#file-upload').fileupload({
maxNumberOfFiles: 6
});
在文档中找到:https://github.com/blueimp/jQuery-File-Upload/wiki/Options#maxnumberoffiles
【讨论】: