Ver Fonte

上传文件

duy há 1 mês atrás
pai
commit
85530cbce8
1 ficheiros alterados com 5 adições e 7 exclusões
  1. 5 7
      src/views/data-fill/components/HcUpload.vue

+ 5 - 7
src/views/data-fill/components/HcUpload.vue

@@ -315,13 +315,11 @@ const submitUpload = async ()=>{
 
     // 创建 FormData 对象
   const formData = new FormData()
-  // 1. 添加文件数组(JSON格式)
-  formData.append('files', JSON.stringify(
-    filesWithSort.map(item => ({
-      sort: item.sort, 
-      file:item.file,
-    })),
-  ))
+
+  // 2. 单独添加每个文件(保持文件二进制数据)
+  filesWithSort.forEach((item, index) => {
+    formData.append(`file_${index}`, item.file, item.file.name)
+  })
 
   // 添加其他必要的上传参数
   formData.append('classify', uploadData.value.classify)