mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
26 lines
611 B
TypeScript
26 lines
611 B
TypeScript
import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import type { UploadProps } from 'antd';
|
|
import { Button, message, Upload } from 'antd';
|
|
|
|
const props: UploadProps = {
|
|
beforeUpload: (file) => {
|
|
const isPNG = file.type === 'image/png';
|
|
if (!isPNG) {
|
|
message.error(`${file.name} is not a png file`);
|
|
}
|
|
return isPNG || Upload.LIST_IGNORE;
|
|
},
|
|
onChange: (info) => {
|
|
console.log(info.fileList);
|
|
},
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload png only</Button>
|
|
</Upload>
|
|
);
|
|
|
|
export default App;
|