uni-app多文件上传丢失后缀格式问题

ChooseImage() {
				uni.chooseImage({
					count: this.maxImg, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['album', 'camera'], //从相册选择
					success: (res) => {
						this.imgList = res.tempFilePaths;
						
						// 如果直接通过tempFilePaths会导致上传文件丢失后缀
						let files = [];
						for (let i = 0; i < res.tempFiles.length; i++) {
							let obj = new Object();
							obj.name = "file";
							obj.uri = res.tempFiles[i].path;
							files.push(obj);
						}
						this.fileList = files;
						this.$emit("imgCallback", files);

					}
				});
			},
uni.uploadFile({
					url: this.$config.apiUrl + this.url.add,
					files: this.imageList,
					fileType:'image',
					name:"file",
					formData: {
					},
					header: {
					},
					success(res) {
						console.log(res)
					},
					fail(err) {
						console.log(err)
					}
				})

后端用这个参数接受即可
MultipartFile[] file

你可能感兴趣的:(uni-app,前端,javascript)