uniapp上传文件

const uploadFilePromise = async (url: string) => {
	return new Promise((resolve, reject) => {
		let a = uni.uploadFile({
			url: `http:***/file/upload`, // 接口地址
			filePath: url, //要上传的文件路径
			name: 'file', //上传文件的key
			header:{
				_sgk: "*****",
				'Content-Type': 'multipart/form-data'
			},
			formData: {
				groupName: '10001',
			},
			success: (res:any) => {
				resolve(res.data)
			},
			fail: (err) => {
				console.log(err, 'uploadFilePromise:e');
			}
		});
	})
};

你可能感兴趣的:(uni-app)