阿龙攻城狮
阿龙攻城狮
  • 发布:2020-06-03 14:30
  • 更新:2021-12-21 17:25
  • 阅读:3002

【报Bug】uniapp 上传图片功能没反应

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: MacOS Mojave 10.14.6

HBuilderX类型: 正式

HBuilderX版本号: 2.7.5

手机系统: iOS

手机系统版本号: iOS 13.2

手机厂商: 苹果

手机机型: iPhone X

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.chooseImage({
sourceType: ['camera', 'album'],
sizeType: ['compressed', 'original'],
count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],
success: (res) => {
this.imageList = this.imageList.concat(res.tempFilePaths);
const value = uni.getStorageSync('online—token')
// 上传到后台服务器
uni.showLoading({
title: '上传中..'
});
for(let k=0;k<res.tempFilePaths.length;k++){
uni.uploadFile({
url: 'https://alon.//**/uploadPicture', //仅为示例,非真实的接口地址
filePath: res.tempFilePaths[k],
header: {
'Authorization' : 'Bearer ' + value.token
},
name: 'file',
success: (uploadFileRes) => {
// 上传成功返回文件路径
_this.info.imageData += uploadFileRes.data + ","
uni.hideLoading();
}
});
}
},
}
})

操作步骤:
uni.chooseImage({  
                    sourceType: ['camera', 'album'],  
                    sizeType: ['compressed', 'original'],  
                    count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],  
                    success: (res) => {  
                        this.imageList = this.imageList.concat(res.tempFilePaths);  
                        const value = uni.getStorageSync('online—token')  
                        // 上传到后台服务器  
                        uni.showLoading({  
                            title: '上传中..'  
                        });  
                        for(let k=0;k<res.tempFilePaths.length;k++){  
                            uni.uploadFile({  
                                url: 'https://alon.**/**/**/uploadPicture', //仅为示例,非真实的接口地址  
                                filePath: res.tempFilePaths[k],  
                                header: {  
                                    'Authorization' : 'Bearer ' + value.token  
                                },  
                                name: 'file',  
                                success: (uploadFileRes) => {  
                                                                        // 上传成功返回文件路径  
                                    _this.info.imageData += uploadFileRes.data + ","  
                                    uni.hideLoading();  
                                }  
                            });  
                        }  
                    },  
                    }  
                })  

预期结果:

希望可以拍摄跟相册都可以上传到服务端

实际结果:

没办法上传手机拍摄的照片

bug描述:

上传图片方式选择的是 sourceType: ['camera', 'album'],

但是我在进行真机调试的时候发现,我拍摄的照片的无法上传到我的服务端,好像本地相册也没有进行保存我拍摄的照片。

相册中选取的照片进行上传是没有问题。

2020-06-03 14:30 负责人:无 分享
已邀请:
阿龙攻城狮

阿龙攻城狮 (作者)

有没有大佬帮忙解决一下

  • 3***@qq.com

    2.7.9我这儿上传也有问题,老版本上传没问题

    2020-06-03 16:11

  • 阿龙攻城狮 (作者)

    回复 3***@qq.com: 你指的是HBuilderX版本嗎?我用的是2.7.5存在問題的。。

    2020-06-03 17:57

  • 7***@qq.com

    请问此问题解决了吗,我也也遇到这个问题,只有IPhone X遇到这个问题,别的手机都正常

    2021-12-08 15:04

7***@qq.com

7***@qq.com

请问此问题解决了吗,我也也遇到这个问题,只有IPhone X遇到这个问题,别的手机都正常

DCloud_iOS_XHY

DCloud_iOS_XHY

使用最新HX测试一下,有问题在反馈吧

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