const chooseFileUpload = ()=>{
uni.chooseFile({
count: 3, //默认100
extension:['.pdf','.doc','.xlsx','.jpg','.jpeg','.png'],
success: function (res) {
const tempFilePaths = res.tempFilePaths;
if(uploadFileData.length>=3){
uni.showToast({
title: '附件最多上传3份',
icon: 'none', // 图标,可选值:success、loading、none
duration: 3000 // 提示框显示时长,单位为毫秒
});
return false;
}
uni.uploadFile({
url: uploadUrl.value,
filePath: tempFilePaths[0],
name: 'file',
header: uploadHeader,
success: (uploadFileRes) => {
interface uploadFileDataInter {
data: {id:number,name:string}
}
let fileSuccessData:uploadFileDataInter = JSON.parse(uploadFileRes.data)
uploadFileData.push({
'id':fileSuccessData.data.id,
'name':fileSuccessData.data.name
})
},
fail: (error)=>{
console.log(error);
}
});
}
});
}
1 个回复
DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信
相同代码运行其他机器是否有这个问题?chooseImage/chooseMedia 运行到空白工程是否有问题,success/fail 会触发吗。得到 tempFile 是否能获取到?建议先使用空白工程说明问题。