Improve upload demo

close #16375
This commit is contained in:
afc163 2019-04-30 15:52:58 +08:00
parent 5ef2cc5a8c
commit 8082b4c2cf
No known key found for this signature in database
GPG Key ID: 738F973FCE5C6B48

View File

@ -13,8 +13,6 @@ title:
2) 读取远程路径并显示链接。
3) 按照服务器返回信息筛选成功上传的文件。
## en-US
You can gain full control over filelist by configuring `fileList`. You can accomplish all kinds of customed functions. The following shows three circumstances:
@ -23,8 +21,6 @@ You can gain full control over filelist by configuring `fileList`. You can accom
2) read from response and show file link.
3) filter successfully uploaded files according to response from server.
````jsx
import { Upload, Button, Icon } from 'antd';
@ -39,11 +35,13 @@ class MyUpload extends React.Component {
}
handleChange = (info) => {
console.log(info);
let fileList = info.fileList;
// 1. Limit the number of uploaded files
// Only to show two recent uploaded files, and old ones will be replaced by the new
fileList = fileList.slice(-2);
console.log(fileList);
// 2. Read from response and show file link
fileList = fileList.map((file) => {
@ -54,14 +52,6 @@ class MyUpload extends React.Component {
return file;
});
// 3. Filter successfully uploaded files according to response from server
fileList = fileList.filter((file) => {
if (file.response) {
return file.response.status === 'success';
}
return false;
});
this.setState({ fileList });
}