a***@gmail.com
a***@gmail.com
  • 发布:2019-07-03 10:08
  • 更新:2021-07-19 19:53
  • 阅读:1583

uni.uploadFile 实现多图片上传 报错 => 安卓

分类:HBuilderX

getImage(){
let that = this
uni.chooseImage({
count: 6 - this.imageslist.length,
success:(res) => {

                    this.imageslist = this.imageslist.concat(res.tempFilePaths);  
                    let imgs = [];  
                    let images = this.imageslist  
                    images.filter((item, index) => {  
                        imgs.unshift({  
                            "name": "image"+index,  
                            "url": item  
                        })  
                    });  
                uni.uploadFile({  
                        url: ''',   
                        files: imgs,  
                        header: {"Content-Type": "multipart/form-data"},  
                        success: (uploadFileRes) => {  
                            // this.url.push(JSON.parse(uploadFileRes.data).data.file_path);  
                            console.log(this.url)  
                            console.log(uploadFileRes.data)  
                       }  
              });  
          }  
        });  

},
实现多图片上传 报错 => 安卓

hbuilderx =>{
uploadFile:fail undefined is not an object (evaluating 'e.indexOf')
}

2019-07-03 10:08 负责人:无 分享
已邀请:
飘过大山

飘过大山 - 99

uploadFile 在小程序里面不支持多张图片上传,所以在uni应该也不行

i***@163.com

i***@163.com

uni.chooseImage({
count: 1,
success: (chooseImageRes) => {
const path = chooseImageRes.tempFilePaths[0]
const file = chooseImageRes.tempFiles[0]

        this.img = path  
        console.log('sdfa')  
        uni.uploadFile({  
          url: `${upload_url}`,  
          files: chooseImageRes.tempFiles.map(tempfile => {  
            return {  
              uri: tempfile.path  
            }  
          }),  
          header: {  
            Authorization: uni.getStorageSync('token'),  
            applicationId: uni.getStorageSync('ApplicationId')  
          },  
          fileType: 'image',  
          formData: {  
            file: file  
          },  
          success: function(){}

该问题目前已经被锁定, 无法添加新回复