1***@163.com
1***@163.com
  • 发布:2024-08-30 14:12
  • 更新:2024-08-30 14:15
  • 阅读:201

uni.uploadFile多文件上传,后端获取不到文件后缀,文件各种参数都丢失了

分类:uni-app
function chooseAvatar() {  
    uni.chooseImage({  
        count: 1, //默认9  
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有  
        sourceType: ['album'], //从相册选择  
        success: res => {  
            iconFile.value = res.tempFiles[0]  
        }  
    });  
}  

function chooseBackground() {  
    uni.chooseImage({  
        count: 1, //默认9  
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有  
        sourceType: ['album'], //从相册选择  
        success: res => {  
            backgroundFile.value = res.tempFiles[0]  
        }  
    });  
}  

export const postForm = (url: string, formData: AnyObject, files: any): Promise<Result> => {  
  const header = {authentication: uni.getStorageSync('authentication')}  
  return new Promise((resolve, reject) => {  
    uni.showLoading({title: '加载中', mask: true}).then()  
    setTimeout(() => {  
      uni.hideLoading()  
    }, 5000)  
    debugger  
    uni.uploadFile({  
      url: baseUrl + url,  
      files: files,  
      formData: formData,  
      header: header,  
      success: (res: UploadFileSuccessCallbackResult) => {  
        console.log(res)  
      },  
      fail: (err: GeneralCallbackResult) => {  
        uni.showToast({  
          title: err.errMsg,  
          icon: "none"  
        }).then()  
        reject(err)  
      },  
      complete: () => {  
        uni.hideLoading()  
      },  
    })  
  })  
}
2024-08-30 14:12 负责人:无 分享
已邀请:
1***@163.com

1***@163.com (作者)

而且,根据文件流去判断文件类型获取到的是text,我上传的明明是图片

要回复问题请先登录注册