javascript - 如何从 axios 上传 2 个文件?
问题描述
最近,我需要一个脚本来使用 axios 将 2 个文件一起发布到我的烧瓶中。
我想使用 append 在我的 vue 中创建一个文件 []。
let formData = new FormData();
formData.append('files',this.file1);
formData.append('files',this.file2);
axios({
method: "post",
data:formData,
headers: {
'Content-Type': "multipart/form-data",
},
url: "http://127.0.0.1:5000/getPic",
responseType: "arraybuffer",
})
而且我还想使用 request.files 接收烧瓶中的 2 个文件:
files=[]
for i in range(len(request.files)):
{files.append(request.files[i])}
file_len =len(files)
if(file_len == 0):
return "未上传文件"
if(file_len == 1):
return "只上传了一个文件"
for i in file_len:
print (files[i].filename)
file1 = Image.open(files[0])
但是当我使用上传 2 个文件时,它告诉我一些错误:
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 0
有谁知道出了什么问题?
解决方案
推荐阅读
- css - 访问 SVG 图像 Flutter 中的组件
- amazon-web-services - AWS Step 函数参数没有移动到下一步
- racket - DrRacket 中参考悬停时图形问号的含义?
- flutter - 如何修复 RenderBox 未在 ListTile 中列出?
- verilog - Verilog 中未解决的对“fulladder”的引用
- c# - 同一张表的多对多关系。英孚
- mysql - 通过(选择结果)mysql更新行
- javascript - JavaScript Click-Event 触发器每次点击触发多次
- java - 为什么 UriComponentsBuilder 忽略空查询参数?
- flutter - RenderShrinkWrappingViewport 需要一个 RenderSliver 类型的子级,但收到了一个 RenderFlex 类型的子级