소스 검색

上传文件

duy 1 개월 전
부모
커밋
85530cbce8
1개의 변경된 파일5개의 추가작업 그리고 7개의 파일을 삭제
  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)