vue[文件上传Required request part ‘file‘ is not present]

时间:2024-04-03 12:12:18

问题发现

文件上传出现:Required request part ‘file’ is not present 这个错误且后端接口通过postman能够请求成功,但前端怎么也上传不成功,明明配置好了请求头而且数据也放置在了data中如:
vue[文件上传Required request part ‘file‘ is not present]
vue[文件上传Required request part ‘file‘ is not present]

问题解决

通过FormData进行文件数据的封装保存,然后直接放入data中即可
vue[文件上传Required request part ‘file‘ is not present]

问题展示:

文件上传接口请求格式无误,通过Postman能够上传
vue[文件上传Required request part ‘file‘ is not present]

vue[文件上传Required request part ‘file‘ is not present]
然而请求头Content-type格式和请求权限都配置好了,然后body中放置了内容,然后报错

vue[文件上传Required request part ‘file‘ is not present]
vue[文件上传Required request part ‘file‘ is not present]
使用axios配置请求信息
vue[文件上传Required request part ‘file‘ is not present]
vue[文件上传Required request part ‘file‘ is not present]