gpt4 book ai didi

javascript - 限制 jQuery-File-Upload 中的文件数量

转载 作者:行者123 更新时间:2023-12-02 17:00:28 24 4
gpt4 key购买 nike

我使用插件 jQuery-File-Upload。如何限制从本地计算机选择文件的数量?

https://github.com/blueimp/jQuery-File-Upload/wiki/Options

最佳答案

您可以通过向输入元素添加 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/>

See demo on fiddle here

关于javascript - 限制 jQuery-File-Upload 中的文件数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25771418/

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