-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
用FormData上传多张图片问题 #10
Comments
In next version, will support uploading files array . |
确实需要乐意上传图片数组的功能 |
@wendux When will next version release? |
Supported! please update dio to 0.1.3 . ExamplesFormData formData = new FormData.from({
"name": "wendux",
"age": 25,
"file1": new UploadFileInfo(new File("./upload.txt"), "upload1.txt"),
// Pass multiple files within an Array
"files": [
new UploadFileInfo(new File("./example/upload.txt"), "upload.txt"),
new UploadFileInfo(new File("./example/upload.txt"), "upload.txt")
]
}); |
HI,更新到 0.1.5 的版本,发现上传多个文件,接收端依旧只能接收到第一个文件,日志如下: I/flutter (25921): {id: 2739, token: C6114DEE9236F025C92A20831312A697, files: [Instance of 'UploadFileInfo', Instance of 'UploadFileInfo']} 其中 583814 看起来之包含了第一张图片的尺寸,缺少第二张图片的尺寸 盼回复,谢谢。 |
@jingjianbing000 你用php原生的全局魔术产量file取一下,可能是你使用的框架不支持(laravel 就不支持),dio多文件上传测试就是用php的。 |
0.12的时候试了下也不行,go后端,我还是用官方http的,就是body不支持中文值,要改下 |
@asmh1989 0.0.12上传文件有问题,然后就紧急修复了,你可以用最新版试试,如果最新版还不行的话, 麻烦贴一下报错信息。 |
@wendux 在php端使用$_FILES接收文件,还是只能接收到1个;1:flutter 端原始参数如下: 2:flutter dio端加入formdata原始代码如下:
3:提交数据时日志如下: 4:PHP端日志如下: 使用0.1.5版本,还是不行; |
@jingjianbing000 php下传数组文件时,key要带上"[]", 下面是我在本地测试的代码,是成功的: FormData formData = new FormData.from(<String,dynamic>{
"files[]":[
new UploadFileInfo(new File("./example/upload.txt"), "upload.txt"),
new UploadFileInfo(new File("./example/upload.txt"), "uploadc.txt")
]
}); php 端调用
可见两个文件接收到了。 |
@wendux 0.1.6 go 后端还是只能识别 一张, 官方http库没问题 |
@wendux 我对比官方http中的代码, 发现
我这边测试通过 |
@asmh1989 你是怎么改的? |
已经提交了个pr |
Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com>
用改方法, 上传多张的时候, 发现服务端(Go/Gin写的), MultipartForm() 里面只能发现 file1
用postman 测试正常
用postman 测试, key 能用一个, 例如 files, 如果也能操作 后台开发能方便一点
@wendux
The text was updated successfully, but these errors were encountered: