--- order: 7 title: zh-CN: 手动上传 en-US: Upload manually --- ## zh-CN `beforeUpload` 返回 `false` 后,手动上传文件。 ## en-US Upload files manually after `beforeUpload` returns `false`. ````jsx import { Upload, Button, Icon, message } from 'antd'; import reqwest from 'reqwest'; class Demo extends React.Component { state = { fileList: [], uploading: false, } handleUpload = () => { const { fileList } = this.state; const formData = new FormData(); fileList.forEach((file) => { formData.append('files[]', file); }); this.setState({ uploading: true, }); // You can use any AJAX library you like reqwest({ url: '//jsonplaceholder.typicode.com/posts/', method: 'post', processData: false, data: formData, success: () => { this.setState({ fileList: [], uploading: false, }); message.success('upload successfully.'); }, error: () => { this.setState({ uploading: false, }); message.error('upload failed.'); }, }); } render() { const { uploading } = this.state; const props = { action: '//jsonplaceholder.typicode.com/posts/', onRemove: (file) => { this.setState(({ fileList }) => { const index = fileList.indexOf(file); const newFileList = fileList.slice(); newFileList.splice(index, 1); return { fileList: newFileList, }; }); }, beforeUpload: (file) => { this.setState(({ fileList }) => ({ fileList: [...fileList, file], })); return false; }, fileList: this.state.fileList, }; return (