upload(item) { let fileList = []; this.createForm.paths = ‘‘; const formData = new FormData(); formData.append(‘file‘, item.file); formData.append(‘paramCode‘, ‘data_source‘); uploadDictionary(formData).then((res) => { if (res.code === 200 && res.data) { this.createForm.paths = res.data.join(); fileList.push({ name: item.file.name }); message.success(‘上传成功‘); item.onSuccess(); // 上传成功后结束文件上传转圈状态 } else { message.error(res.message || ‘上传失败‘); item.onError(); // 返回报错 } this.setState({ fileList }); }); }
<Upload.Dragger beforeUpload={() => beforeUpload()} customRequest={() => upload()} accept={‘.xls‘} > <p className="ant-upload-drag-icon"> <CloudUploadOutlined /> </p> <p className="ant-upload-text">将文件拖到此处,或点击上传</p> </Upload.Dragger>