Parcourir la source

校检文件名是否包含特殊字符

RuoYi il y a 1 an
Parent
commit
5b485e7934

+ 6 - 1
ruoyi-ui/src/components/FileUpload/index.vue

@@ -118,10 +118,15 @@ export default {
118 118
         const fileExt = fileName[fileName.length - 1];
119 119
         const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
120 120
         if (!isTypeOk) {
121
-          this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
121
+          this.$modal.msgError(`文件格式不正确请上传${this.fileType.join("/")}格式文件!`);
122 122
           return false;
123 123
         }
124 124
       }
125
+      // 校检文件名是否包含特殊字符
126
+      if (file.name.includes(',')) {
127
+        this.$modal.msgError('文件名不正确,不能包含英文逗号!');
128
+        return false;
129
+      }
125 130
       // 校检文件大小
126 131
       if (this.fileSize) {
127 132
         const isLt = file.size / 1024 / 1024 < this.fileSize;

+ 4 - 0
ruoyi-ui/src/components/ImageUpload/index.vue

@@ -133,6 +133,10 @@ export default {
133 133
         this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
134 134
         return false;
135 135
       }
136
+      if (file.name.includes(',')) {
137
+        this.$modal.msgError('文件名不正确,不能包含英文逗号!');
138
+        return false;
139
+      }
136 140
       if (this.fileSize) {
137 141
         const isLt = file.size / 1024 / 1024 < this.fileSize;
138 142
         if (!isLt) {