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=> {}
});
}
})
1 个回复
1***@qq.com - mjs
你好解决了吗