{statusCode: 400, data: "{"code":400,"totalCount":0}", header: {…}, cookies: Array(0), errMsg: "uploadFile:ok"}cookies: []data: "{"code":400,"totalCount":0}"errMsg: "uploadFile:ok"header:Connection: "keep-alive"Content-Type: "application/json"Date: "Wed, 28 Jun 2023 09:36:06 GMT"Server: "nginx"Transfer-Encoding: "chunked"Vary: "Origin,Access-Control-Request-Method,Access-Control-Request-Headers"constructor: (...)hasOwnProperty: (...)isPrototypeOf: (...)propertyIsEnumerable: (...)toLocaleString: (...)toString: (...)valueOf: (...)__defineGetter__: (...)__defineSetter__: (...)__lookupGetter__: (...)__lookupSetter__: (...)__proto__: ObjectstatusCode: 400constructor: (...)hasOwnProperty: (...)isPrototypeOf: (...)propertyIsEnumerable: (...)toLocaleString: (...)toString: (...)valueOf: (...)__defineGetter__: (...)__defineSetter__: (...)__lookupGetter__: (...)__lookupSetter__: (...)__proto__: Object报错的的代码
wx.uploadFile上传失败报错400?这是代码片段 upload(index, url) { console.log(url,"url"); return new Promise((resolve, reject) => { uni.uploadFile({ url: this.serverUrl, name: 'file', // header: this.header, // header:{"Content-Type": "multipart/form-data"}, // formData: { // // fileName: url.name, // // ...this.formData // 'user': 'test' // }, filePath: url.path, success: (res) => { console.log(res,2222); if (res.statusCode == 200) { //返回结果 此处需要按接口实际返回进行修改 let data = JSON.parse(res.data.replace(/\ufeff/g, "") || "{}") console.log(data,3333) if (data.code === '200') { this.fileList[index] = data.data //根据实际情况修改 } else { // 上传失败 } resolve() } else { reject(res.msg,444) } console.log(res, 'chengong'); }, fail: function(res) { console.log(res, 'shibai') reject(res) } }) }) }, 上传怎么都是400上传不成功,同样的url图片是可以的pdf就不行
2023-06-28