0

我在单击浏览按钮时一一添加三个文件,然后如果第三个文件重复,则不应将其添加到放置区。我不知道我哪里错了。

插件链接:https ://plugins.krajee.com/file-input

看这张图片:

在此处输入图像描述

我正在使用以下 JS 配置代码:

                    $("#files").fileinput({
                    theme: "fas",
                    uploadUrl: "SampleController/SaveAttachmentData",
                    showUpload: true,
                    showRemove: false,
                    showCaption: false,
                    showMultipleNames: false,
                    minFileCount: 1,
                    maxFileCount: 10,
                    maxTotalFileCount: 10,
                    browseClass: "btn btn-outline-primary rounded z-depth-0 m-0 p-0 mt-3 btn-browse",
                    removeClass: "btn btn-sm m-0 z-depth-0",
                    uploadClass: "btn btn-primary rounded z-depth-0 m-0 p-0 mt-3 btn-upload",
                    cancelClass: "btn btn-default float-right rounded z-depth-0 m-0 p-0 mt-3 btn-cancel",
                    overwriteInitial: false,
                    initialPreviewAsData: true, // defaults markup
                    allowedFileExtensions: ['doc', 'docx', 'pdf', 'xlsx', 'xls', 'ppt', 'pptx', 'png', 'jpg'],
                    uploadAsync: false,
                    initialPreviewConfig: [{
                        frameAttr: {
                            title: 'My Custom Title',
                        }
                    }],
                    uploadExtraData: function () {
                        return {
                            registrationId: $("#RegistrationId").val(),
                            filePath: $('#CurrCatName').val()
                        };
                    },
                    fileActionSettings: {
                        showZoom: false,
                        showUpload: false,
                        //indicatorNew: "",
                        showDrag: false
                    },
                    preferIconicPreview: true, // this will force thumbnails to display icons for following file extensions
                    previewFileIconSettings: { // configure your icon file extensions
                        'doc': '<i class="fas fa-file-word ic-file-word color-doc"></i>',
                        'xls': '<i class="fas fa-file-excel ic-file-excel color-excel"></i>',
                        'ppt': '<i class="fas fa-file-powerpoint ic-file-ppt color-ppt"></i>',
                        'pdf': '<i class="fas fa-file-pdf ic-file-pdf color-ppt"></i>',
                        'zip': '<i class="fas fa-file-archive ic-file text-primary"></i>',
                        'htm': '<i class="fas fa-file-code ic-file text-primary"></i>'
                        //'txt': '<i class="fas fa-file-alt ic-file"></i>',
                        //'mov': '<i class="fas fa-file-video ic-file"></i>',
                        //'mp3': '<i class="fas fa-file-audio ic-file"></i>'
                        // note for these file types below no extension determination logic
                        // has been configured (the keys itself will be used as extensions)
                        //'jpg': '<i class="fas fa-file-image ic-file-img"></i>',
                        //'jpeg': '<i class="fas fa-file-image ic-file-img"></i>',
                        //'gif': '<i class="fas fa-file-image ic-file-img"></i>',
                        //'png': '<i class="fas fa-file-image ic-file-img"></i>'
                    },
                    previewSettings: {
                        image: { width: "50px", height: "auto" },
                        html: { width: "50px", height: "auto" },
                        other: { width: "50px", height: "auto" }
                    },
                    previewFileExtSettings: { // configure the logic for determining icon file extensions
                        'doc': function (ext) {
                            return ext.match(/(doc|docx)$/i);
                        },
                        'xls': function (ext) {
                            return ext.match(/(xls|xlsx)$/i);
                        },
                        'ppt': function (ext) {
                            return ext.match(/(ppt|pptx)$/i);
                        },
                        'zip': function (ext) {
                            return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
                        },
                        'htm': function (ext) {
                            return ext.match(/(htm|html)$/i);
                        },
                        'txt': function (ext) {
                            return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
                        },
                        'mov': function (ext) {
                            return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
                        },
                        'mp3': function (ext) {
                            return ext.match(/(mp3|wav)$/i);
                        }
                    }
                    //enctype: 'multipart/form-data',
                });

html代码是:

<input class="fileUploader" type="file" id="files" name="files" multiple>

另一个是当我添加一个文件名中包含空格的文件时,我收到控制台错误:

未捕获的错误:语法错误,无法识别的表达式:#thumb-files-10166_ImportParentsExcelSample_(2).xlsx

我该如何解决?

语言环境中的文件名:ImportParentsExcelSample (2)

在此处输入图像描述

在此处输入图像描述

4

0 回答 0