Liyuan Li 5 years ago
parent
commit
0198d71c2d
2 changed files with 4 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 3 5
      src/ts/upload/index.ts

+ 1 - 0
CHANGELOG.md

@@ -68,6 +68,7 @@
 
 ### v3.3.6 / 2020-07-xx
 
+* [547](https://github.com/Vanessa219/vditor/issues/547) 文件上传 format 第一个参数 files 为空数组 `修复缺陷`
 * [562](https://github.com/Vanessa219/vditor/issues/562) 为上传添加 fieldName 选项 `引入特性`
 * [553](https://github.com/Vanessa219/vditor/issues/553) 子任务列表回车问题 `改进功能`
 * 添加 `options.upload.fieldName`

+ 3 - 5
src/ts/upload/index.ts

@@ -211,15 +211,10 @@ const uploadFiles = (vditor: IVditor, files: FileList | DataTransferItemList | F
     setHeaders(vditor, xhr);
     vditor.upload.isUploading = true;
     editorElement.setAttribute("contenteditable", "false");
-
     xhr.onreadystatechange = () => {
         if (xhr.readyState === XMLHttpRequest.DONE) {
             vditor.upload.isUploading = false;
-            if (element) {
-                element.value = "";
-            }
             editorElement.setAttribute("contenteditable", "true");
-
             if (xhr.status === 200) {
                 if (vditor.options.upload.success) {
                     vditor.options.upload.success(editorElement, xhr.responseText);
@@ -237,6 +232,9 @@ const uploadFiles = (vditor: IVditor, files: FileList | DataTransferItemList | F
                     vditor.tip.show(xhr.responseText);
                 }
             }
+            if (element) {
+                element.value = "";
+            }
             vditor.upload.element.style.display = "none";
         }
     };