如何在上传前选择文件时过滤 jQuery 文件类型?

How to have jQuery filtered file types on selecting files before uploading?

我正在使用 jQuery-File-Upload,我想在选择时过滤文件类型。这意味着每个具有未接受扩展名的文件都将隐藏在文件资源管理器小部件中,用户看不到它们。 我尝试为 "acceptFileTypes" 导入值,但它只在选择后验证文件类型,这不是我想要的。 有人帮忙吗?

这只是我的示例代码。我不能给官方看。对不起这个。

$('#fileupload').fileupload('option', {
            url: '//localhost/',
            maxFileSize: 5000000,
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
            process: [
                {
                    action: 'load',
                    fileTypes: /^image\/(gif|jpeg|png)$/,
                    maxFileSize: 20000000 // 20MB
                },
                {
                    action: 'resize',
                    maxWidth: 1440,
                    maxHeight: 900
                },
                {
                    action: 'save'
                }
            ]
        });

使用accept属性过滤文件类型。请参考下面我的示例代码。

<!--Code to access only for excel files-->
<input type="file" accept=".xls,.xlsx" />