欢呀
欢呀
  • 发布:2021-12-07 17:43
  • 更新:2023-03-30 11:31
  • 阅读:1713

h5上传图片选择相册上传正常,相机拍照上传无效

分类:uni-app

uni上传图片选择相册上传正常,相机拍照上传无效

代码

uni.chooseImage({
count: num || 9, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: code == 4?['camera']:['album'], //从相册选择
success: function(res) {
console.log(res);
// let tempFilePaths = imgRes.tempFilePaths
let files = res.tempFiles.map((item,index)=>{
return {name:'files',file:item,uri:res.tempFilePaths[index]}
})
let houzui = /.[^.]+$/.exec(res.tempFiles[0].name)
alert(JSON.stringify(res))
uni.uploadFile({
url: 'https://xmcr.nngyun.cn/WisdomSchool/api/common/attach/upload',
// file: files[0].file,
filePath:res.tempFilePaths[0],
name:'files',
formData: {
code: 4,
name:files[0].uri
},
header:{
// 'content-type': 'multipart/form-data',
'Authorization':_this.$db.get('authorization'),
},
success: result => {},
fail: result =>{

                            let dataBase = JSON.parse(result.data)  
                            // alert(dataBase)  
                        },  
                        complete:result=> {}  

                    });  
                }  
            })
2021-12-07 17:43 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com - mjs

你好解决了吗

要回复问题请先登录注册