uniapp多图上传uni.chooseImage上传照片uni.uploadFile
代码示例:
/**上传照片 多图*/getImage() {uni.chooseImage({count: 9, //默认9sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有sourceType: ['album'], //从相册选择//function函数改成箭头函数//success: function(res) {success: (res) => {//1.上传多图 循环请求接口res.tempFilePaths.forEach((item) => {uni.uploadFile({url: config.baseUrl + '/infra/file/upload', //上传的服务器地址//filePath: res.tempFilePaths[0],//2.上传单图filePath: item,//多图name: 'file',formData: {//'file': res.tempFilePaths[0],//上传单图'file': item,//多图},header: {['Authorization']: "Bearer " + uni.getStorageSync('token'),['tenant-id']: '1',},success: (uploadFileRes) => {let uploadUrl = JSON.parse(uploadFileRes.data).data;this.photoList.push(uploadUrl);//收集返回的图片}})})}});},