Skip to content
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

请指教,关于file文件上传问题 #17

Closed
nongzhenli opened this issue Nov 10, 2020 · 2 comments
Closed

请指教,关于file文件上传问题 #17

nongzhenli opened this issue Nov 10, 2020 · 2 comments

Comments

@nongzhenli
Copy link

nongzhenli commented Nov 10, 2020

已知文档处写明:data支持的文件类型只有Object/String/ArrayBuffer</code>这个真跟我没啥关系 0.0

场景需求:

上传多图片file[]后端这样子接收,一般都会这么操作哇,先说一般情况下~(且携带其他信息,一同formData提交)

操作 :(H5端下测试)

尝试使用post请求,JSON对象作为data参数,设置header Content-type: ''application/x-www-form-urlencoded; charset=UTF-8"
成功上传格式 FormData,

问题:

  • file无法无法实现多个 file[]...
  • file 变成 [obejct File], [obejct File] ... (应该是(binary) 才是的捏)

请问作者,如何去实现可上传FormData参数呢?(这个问题我看下源码,不知道是从那部开始做转换的呢)
image

@lei-mu
Copy link
Owner

lei-mu commented Nov 11, 2020

这个问题可以加QQ详细沟通一下;370306150
具体可以分几个场景;

  1. formData 传参。没有file 文件。 置header Content-type: ''application/x-www-form-urlencoded; charset=UTF-8"
    成功上传格式 FormData
  2. formData 传参。 有file 文件。 这时候就要用luch-request 里的upload [方法(等同于uni的uni.uploadFile(OBJECT))。uni.uploadFile(OBJECT)
    多file 同时上传。使用files参数。其他formData 参数,使用formData这个参数

@nongzhenli
Copy link
Author

这个问题可以加QQ详细沟通一下;370306150
具体可以分几个场景;

  1. formData 传参。没有file 文件。 置header Content-type: ''application/x-www-form-urlencoded; charset=UTF-8"
    成功上传格式 FormData
  2. formData 传参。 有file 文件。 这时候就要用luch-request 里的upload [方法(等同于uni的uni.uploadFile(OBJECT))。uni.uploadFile(OBJECT)
    多file 同时上传。使用files参数。其他formData 参数,使用formData这个参数

好的,今晚试试~感谢

@lei-mu lei-mu closed this as completed Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants