# uploadFile ^6.8

http文件上传

# 请求参数

Prop Type Value Comment
url String - 服务器地址
filePath Object - 要上传文件资源的路径 (本地相对路径)
name Number - 文件对应的 key
header Number - HTTP 请求的 Header,Header 中不能设置 Referer
formData Number - HTTP 请求中其他额外的 form data
timeout Number - 超时时间,单位为毫秒

# 参数代码示例


    let params = {
        url: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3105753044,45676271&fm=26&gp=0.jpg',
        filePath: 'downFiles/timg.jpeg',
        name: "keyname",
        header: {},
        formData: {},  //HTTP 请求中其他额外的 form data
        timeout: 10000
    }

1
2
3
4
5
6
7
8
9
10

# 接口调用示例


      let params = {url: this.url, filePath: this.filePath, name: this.name, header: this.header, formData: this.formData, timeout: this.timeout}
      this.$bridge
        .uploadFile(params)
        .then(res => {    
          this.$alert(res)
        })
        .catch(err => {
          this.$toast(err)
        })

1
2
3
4
5
6
7
8
9
10
11

# 返回参数

  • 成功时返回
Prop Type Comment
code Number -
msg String -

# 返回示例


{
    "code": 0,
    "msg": "success"
}

1
2
3
4
5
6
更新时间: 7/27/2021, 11:23:45 AM