You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1153 lines
75 KiB
1153 lines
75 KiB
"use strict";(self.webpackChunkantd=self.webpackChunkantd||[]).push([[9466],{360124:function(m,r,t){t.r(r);var g=t(502143),f=t(968521),v=t(720719),h=t(28840),l=t(759907),i=t(828089),_=t(825673),Z=t(902068),w=t(574399),b=t(863942),y=t(316073),x=t(24628),U=t(719260),k=t(956140),c=t(127179),s=t(905388),P=t(40428),L=t(606965),O=t(268696),j=t(587302),o=t(424128),D=t(249706),C=t(795127),T=t(116846),E=t(212039),I=t(73024),S=t(553913),a=t(606641),d=t(667294),e=t(370917);function u(){var p=(0,a.eL)(),n=p.texts;return(0,e.tZ)(a.dY,null,(0,e.tZ)(d.Fragment,null,(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("p",null,n[0].value),(0,e.tZ)("h2",{id:"when-to-use"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#when-to-use",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"When To Use"),(0,e.tZ)("p",null,n[1].value),(0,e.tZ)("ul",null,(0,e.tZ)("li",null,n[2].value),(0,e.tZ)("li",null,n[3].value),(0,e.tZ)("li",null,n[4].value)),(0,e.tZ)("h2",{id:"examples"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#examples",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Examples")),(0,e.tZ)(s.Z,{items:[{demo:{id:"components-upload-demo-basic"},previewerProps:{title:"Upload by clicking",filename:"components/upload/demo/basic.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, message, Upload } from 'antd';
|
|
const props = {
|
|
name: 'file',
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
headers: {
|
|
authorization: 'authorization-text',
|
|
},
|
|
onChange(info) {
|
|
if (info.file.status !== 'uploading') {
|
|
console.log(info.file, info.fileList);
|
|
}
|
|
if (info.file.status === 'done') {
|
|
message.success(\`\${info.file.name} file uploaded successfully\`);
|
|
} else if (info.file.status === 'error') {
|
|
message.error(\`\${info.file.name} file upload failed.\`);
|
|
}
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Classic mode. File selection dialog pops up when upload button is clicked.</p>"}},{demo:{id:"components-upload-demo-avatar"},previewerProps:{title:"Avatar",filename:"components/upload/demo/avatar.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
|
|
import { message, Upload } from 'antd';
|
|
const getBase64 = (img, callback) => {
|
|
const reader = new FileReader();
|
|
reader.addEventListener('load', () => callback(reader.result));
|
|
reader.readAsDataURL(img);
|
|
};
|
|
const beforeUpload = (file) => {
|
|
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
if (!isJpgOrPng) {
|
|
message.error('You can only upload JPG/PNG file!');
|
|
}
|
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
if (!isLt2M) {
|
|
message.error('Image must smaller than 2MB!');
|
|
}
|
|
return isJpgOrPng && isLt2M;
|
|
};
|
|
const App = () => {
|
|
const [loading, setLoading] = useState(false);
|
|
const [imageUrl, setImageUrl] = useState();
|
|
const handleChange = (info) => {
|
|
if (info.file.status === 'uploading') {
|
|
setLoading(true);
|
|
return;
|
|
}
|
|
if (info.file.status === 'done') {
|
|
// Get this url from response in real world.
|
|
getBase64(info.file.originFileObj, (url) => {
|
|
setLoading(false);
|
|
setImageUrl(url);
|
|
});
|
|
}
|
|
};
|
|
const uploadButton = (
|
|
<div>
|
|
{loading ? <LoadingOutlined /> : <PlusOutlined />}
|
|
<div
|
|
style={{
|
|
marginTop: 8,
|
|
}}
|
|
>
|
|
Upload
|
|
</div>
|
|
</div>
|
|
);
|
|
return (
|
|
<>
|
|
<Upload
|
|
name="avatar"
|
|
listType="picture-card"
|
|
className="avatar-uploader"
|
|
showUploadList={false}
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
beforeUpload={beforeUpload}
|
|
onChange={handleChange}
|
|
>
|
|
{imageUrl ? (
|
|
<img
|
|
src={imageUrl}
|
|
alt="avatar"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
/>
|
|
) : (
|
|
uploadButton
|
|
)}
|
|
</Upload>
|
|
<Upload
|
|
name="avatar"
|
|
listType="picture-circle"
|
|
className="avatar-uploader"
|
|
showUploadList={false}
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
beforeUpload={beforeUpload}
|
|
onChange={handleChange}
|
|
>
|
|
{imageUrl ? (
|
|
<img
|
|
src={imageUrl}
|
|
alt="avatar"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
/>
|
|
) : (
|
|
uploadButton
|
|
)}
|
|
</Upload>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:`<p>Click to upload user's avatar, and validate size and format of picture with <code>beforeUpload</code>.</p>
|
|
<blockquote>
|
|
<p>The return value of function <code>beforeUpload</code> can be a Promise to check asynchronously. <a href="https://upload-react-component.vercel.app/demo/before-upload#beforeupload">demo</a></p>
|
|
</blockquote>`}},{demo:{id:"components-upload-demo-defaultfilelist"},previewerProps:{title:"Default Files",filename:"components/upload/demo/defaultFileList.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const props = {
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
onChange({ file, fileList }) {
|
|
if (file.status !== 'uploading') {
|
|
console.log(file, fileList);
|
|
}
|
|
},
|
|
defaultFileList: [
|
|
{
|
|
uid: '1',
|
|
name: 'xxx.png',
|
|
status: 'uploading',
|
|
url: 'http://www.baidu.com/xxx.png',
|
|
percent: 33,
|
|
},
|
|
{
|
|
uid: '2',
|
|
name: 'yyy.png',
|
|
status: 'done',
|
|
url: 'http://www.baidu.com/yyy.png',
|
|
},
|
|
{
|
|
uid: '3',
|
|
name: 'zzz.png',
|
|
status: 'error',
|
|
response: 'Server Error 500',
|
|
// custom error message to show
|
|
url: 'http://www.baidu.com/zzz.png',
|
|
},
|
|
],
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Use <code>defaultFileList</code> for uploaded files when page init.</p>"}},{demo:{id:"components-upload-demo-picture-card"},previewerProps:{title:"Pictures Wall",filename:"components/upload/demo/picture-card.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
import { Modal, Upload } from 'antd';
|
|
const getBase64 = (file) =>
|
|
new Promise((resolve, reject) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.onload = () => resolve(reader.result);
|
|
reader.onerror = (error) => reject(error);
|
|
});
|
|
const App = () => {
|
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
const [previewImage, setPreviewImage] = useState('');
|
|
const [previewTitle, setPreviewTitle] = useState('');
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-1',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-2',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-3',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-4',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-xxx',
|
|
percent: 50,
|
|
name: 'image.png',
|
|
status: 'uploading',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-5',
|
|
name: 'image.png',
|
|
status: 'error',
|
|
},
|
|
]);
|
|
const handleCancel = () => setPreviewOpen(false);
|
|
const handlePreview = async (file) => {
|
|
if (!file.url && !file.preview) {
|
|
file.preview = await getBase64(file.originFileObj);
|
|
}
|
|
setPreviewImage(file.url || file.preview);
|
|
setPreviewOpen(true);
|
|
setPreviewTitle(file.name || file.url.substring(file.url.lastIndexOf('/') + 1));
|
|
};
|
|
const handleChange = ({ fileList: newFileList }) => setFileList(newFileList);
|
|
const uploadButton = (
|
|
<div>
|
|
<PlusOutlined />
|
|
<div
|
|
style={{
|
|
marginTop: 8,
|
|
}}
|
|
>
|
|
Upload
|
|
</div>
|
|
</div>
|
|
);
|
|
return (
|
|
<>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture-card"
|
|
fileList={fileList}
|
|
onPreview={handlePreview}
|
|
onChange={handleChange}
|
|
>
|
|
{fileList.length >= 8 ? null : uploadButton}
|
|
</Upload>
|
|
<Modal open={previewOpen} title={previewTitle} footer={null} onCancel={handleCancel}>
|
|
<img
|
|
alt="example"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
src={previewImage}
|
|
/>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>After users upload picture, the thumbnail will be shown in list. The upload button will disappear when count meets limitation.</p>"}},{demo:{id:"components-upload-demo-picture-circle"},previewerProps:{title:"Pictures with picture-circle type",filename:"components/upload/demo/picture-circle.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { PlusOutlined } from '@ant-design/icons';
|
|
import { Modal, Upload } from 'antd';
|
|
const getBase64 = (file) =>
|
|
new Promise((resolve, reject) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.onload = () => resolve(reader.result);
|
|
reader.onerror = (error) => reject(error);
|
|
});
|
|
const App = () => {
|
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
const [previewImage, setPreviewImage] = useState('');
|
|
const [previewTitle, setPreviewTitle] = useState('');
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-1',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-xxx',
|
|
percent: 50,
|
|
name: 'image.png',
|
|
status: 'uploading',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-5',
|
|
name: 'image.png',
|
|
status: 'error',
|
|
},
|
|
]);
|
|
const handleCancel = () => setPreviewOpen(false);
|
|
const handlePreview = async (file) => {
|
|
if (!file.url && !file.preview) {
|
|
file.preview = await getBase64(file.originFileObj);
|
|
}
|
|
setPreviewImage(file.url || file.preview);
|
|
setPreviewOpen(true);
|
|
setPreviewTitle(file.name || file.url.substring(file.url.lastIndexOf('/') + 1));
|
|
};
|
|
const handleChange = ({ fileList: newFileList }) => setFileList(newFileList);
|
|
const uploadButton = (
|
|
<div>
|
|
<PlusOutlined />
|
|
<div
|
|
style={{
|
|
marginTop: 8,
|
|
}}
|
|
>
|
|
Upload
|
|
</div>
|
|
</div>
|
|
);
|
|
return (
|
|
<>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture-circle"
|
|
fileList={fileList}
|
|
onPreview={handlePreview}
|
|
onChange={handleChange}
|
|
>
|
|
{fileList.length >= 8 ? null : uploadButton}
|
|
</Upload>
|
|
<Modal open={previewOpen} title={previewTitle} footer={null} onCancel={handleCancel}>
|
|
<img
|
|
alt="example"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
src={previewImage}
|
|
/>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Alternative display for picture-card.</p>"}},{demo:{id:"components-upload-demo-filelist"},previewerProps:{title:"Complete control over file list",filename:"components/upload/demo/fileList.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const App = () => {
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-1',
|
|
name: 'xxx.png',
|
|
status: 'done',
|
|
url: 'http://www.baidu.com/xxx.png',
|
|
},
|
|
]);
|
|
const handleChange = (info) => {
|
|
let newFileList = [...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
|
|
newFileList = newFileList.slice(-2);
|
|
|
|
// 2. Read from response and show file link
|
|
newFileList = newFileList.map((file) => {
|
|
if (file.response) {
|
|
// Component will show file.url as link
|
|
file.url = file.response.url;
|
|
}
|
|
return file;
|
|
});
|
|
setFileList(newFileList);
|
|
};
|
|
const props = {
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
onChange: handleChange,
|
|
multiple: true,
|
|
};
|
|
return (
|
|
<Upload {...props} fileList={fileList}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:`<p>You can gain full control over filelist by configuring <code>fileList</code>. You can accomplish all kinds of customized functions. The following shows two circumstances:</p>
|
|
<ol>
|
|
<li>
|
|
<p>limit the number of uploaded files.</p>
|
|
</li>
|
|
<li>
|
|
<p>read from response and show file link.</p>
|
|
</li>
|
|
</ol>`}},{demo:{id:"components-upload-demo-drag"},previewerProps:{title:"Drag and Drop",filename:"components/upload/demo/drag.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { InboxOutlined } from '@ant-design/icons';
|
|
import { message, Upload } from 'antd';
|
|
const { Dragger } = Upload;
|
|
const props = {
|
|
name: 'file',
|
|
multiple: true,
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
onChange(info) {
|
|
const { status } = info.file;
|
|
if (status !== 'uploading') {
|
|
console.log(info.file, info.fileList);
|
|
}
|
|
if (status === 'done') {
|
|
message.success(\`\${info.file.name} file uploaded successfully.\`);
|
|
} else if (status === 'error') {
|
|
message.error(\`\${info.file.name} file upload failed.\`);
|
|
}
|
|
},
|
|
onDrop(e) {
|
|
console.log('Dropped files', e.dataTransfer.files);
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Dragger {...props}>
|
|
<p className="ant-upload-drag-icon">
|
|
<InboxOutlined />
|
|
</p>
|
|
<p className="ant-upload-text">Click or drag file to this area to upload</p>
|
|
<p className="ant-upload-hint">
|
|
Support for a single or bulk upload. Strictly prohibited from uploading company data or other
|
|
banned files.
|
|
</p>
|
|
</Dragger>
|
|
);
|
|
export default App;
|
|
`,description:`<p>You can drag files to a specific area, to upload. Alternatively, you can also upload by selecting.</p>
|
|
<p>We can upload several files at once in modern browsers by giving the input the <code>multiple</code> attribute.</p>`}},{demo:{id:"components-upload-demo-directory"},previewerProps:{title:"Upload directory",filename:"components/upload/demo/directory.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const App = () => (
|
|
<Upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76" directory>
|
|
<Button icon={<UploadOutlined />}>Upload Directory</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>You can select and upload a whole directory.</p>"}},{demo:{id:"components-upload-demo-upload-manually"},previewerProps:{title:"Upload manually",filename:"components/upload/demo/upload-manually.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, message, Upload } from 'antd';
|
|
const App = () => {
|
|
const [fileList, setFileList] = useState([]);
|
|
const [uploading, setUploading] = useState(false);
|
|
const handleUpload = () => {
|
|
const formData = new FormData();
|
|
fileList.forEach((file) => {
|
|
formData.append('files[]', file);
|
|
});
|
|
setUploading(true);
|
|
// You can use any AJAX library you like
|
|
fetch('https://www.mocky.io/v2/5cc8019d300000980a055e76', {
|
|
method: 'POST',
|
|
body: formData,
|
|
})
|
|
.then((res) => res.json())
|
|
.then(() => {
|
|
setFileList([]);
|
|
message.success('upload successfully.');
|
|
})
|
|
.catch(() => {
|
|
message.error('upload failed.');
|
|
})
|
|
.finally(() => {
|
|
setUploading(false);
|
|
});
|
|
};
|
|
const props = {
|
|
onRemove: (file) => {
|
|
const index = fileList.indexOf(file);
|
|
const newFileList = fileList.slice();
|
|
newFileList.splice(index, 1);
|
|
setFileList(newFileList);
|
|
},
|
|
beforeUpload: (file) => {
|
|
setFileList([...fileList, file]);
|
|
return false;
|
|
},
|
|
fileList,
|
|
};
|
|
return (
|
|
<>
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Select File</Button>
|
|
</Upload>
|
|
<Button
|
|
type="primary"
|
|
onClick={handleUpload}
|
|
disabled={fileList.length === 0}
|
|
loading={uploading}
|
|
style={{
|
|
marginTop: 16,
|
|
}}
|
|
>
|
|
{uploading ? 'Uploading' : 'Start Upload'}
|
|
</Button>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Upload files manually after <code>beforeUpload</code> returns <code>false</code>.</p>"}},{demo:{id:"components-upload-demo-upload-png-only"},previewerProps:{title:"Upload png file only",filename:"components/upload/demo/upload-png-only.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, message, Upload } from 'antd';
|
|
const props = {
|
|
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 = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload png only</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p><code>beforeUpload</code> only prevent upload behavior when return false or reject promise, the prevented file would still show in file list. Here is the example you can keep prevented files out of list by return <code>UPLOAD.LIST_IGNORE</code>.</p>"}},{demo:{id:"components-upload-demo-picture-style"},previewerProps:{title:"Pictures with list style",filename:"components/upload/demo/picture-style.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const fileList = [
|
|
{
|
|
uid: '0',
|
|
name: 'xxx.png',
|
|
status: 'uploading',
|
|
percent: 33,
|
|
},
|
|
{
|
|
uid: '-1',
|
|
name: 'yyy.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
thumbUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-2',
|
|
name: 'zzz.png',
|
|
status: 'error',
|
|
},
|
|
];
|
|
const App = () => (
|
|
<>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture"
|
|
defaultFileList={[...fileList]}
|
|
>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
<br />
|
|
<br />
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture"
|
|
defaultFileList={[...fileList]}
|
|
className="upload-list-inline"
|
|
>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
</>
|
|
);
|
|
export default App;
|
|
`,description:"<p>If uploaded file is a picture, the thumbnail can be shown. <code>IE8/9</code> do not support local thumbnail show. Please use <code>thumbUrl</code> instead.</p>",style:`/* tile uploaded pictures */
|
|
.upload-list-inline .ant-upload-list-item {
|
|
float: left;
|
|
width: 200px;
|
|
margin-inline-end: 8px;
|
|
}
|
|
|
|
.ant-upload-rtl.upload-list-inline .ant-upload-list-item {
|
|
float: right;
|
|
}`}},{demo:{id:"components-upload-demo-preview-file"},previewerProps:{title:"Customize preview file",filename:"components/upload/demo/preview-file.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const props = {
|
|
action: '//jsonplaceholder.typicode.com/posts/',
|
|
listType: 'picture',
|
|
previewFile(file) {
|
|
console.log('Your upload file:', file);
|
|
// Your process logic. Here we just mock to the same file
|
|
return fetch('https://next.json-generator.com/api/json/get/4ytyBoLK8', {
|
|
method: 'POST',
|
|
body: file,
|
|
})
|
|
.then((res) => res.json())
|
|
.then(({ thumbnail }) => thumbnail);
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Customize local preview. Can handle with non-image format files such as video.</p>"}},{demo:{id:"components-upload-demo-max-count"},previewerProps:{title:"Max Count",filename:"components/upload/demo/max-count.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Space, Upload } from 'antd';
|
|
const App = () => (
|
|
<Space
|
|
direction="vertical"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
size="large"
|
|
>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture"
|
|
maxCount={1}
|
|
>
|
|
<Button icon={<UploadOutlined />}>Upload (Max: 1)</Button>
|
|
</Upload>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture"
|
|
maxCount={3}
|
|
multiple
|
|
>
|
|
<Button icon={<UploadOutlined />}>Upload (Max: 3)</Button>
|
|
</Upload>
|
|
</Space>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Limit files with <code>maxCount</code>. Will replace current one when <code>maxCount</code> is <code>1</code>.</p>"}},{demo:{id:"components-upload-demo-transform-file"},previewerProps:{title:"Transform file before request",filename:"components/upload/demo/transform-file.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const props = {
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
listType: 'picture',
|
|
beforeUpload(file) {
|
|
return new Promise((resolve) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.onload = () => {
|
|
const img = document.createElement('img');
|
|
img.src = reader.result;
|
|
img.onload = () => {
|
|
const canvas = document.createElement('canvas');
|
|
canvas.width = img.naturalWidth;
|
|
canvas.height = img.naturalHeight;
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.drawImage(img, 0, 0);
|
|
ctx.fillStyle = 'red';
|
|
ctx.textBaseline = 'middle';
|
|
ctx.font = '33px Arial';
|
|
ctx.fillText('Ant Design', 20, 20);
|
|
canvas.toBlob((result) => resolve(result));
|
|
};
|
|
};
|
|
});
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Use <code>beforeUpload</code> for transform file before request such as add a watermark.</p>"}},{demo:{id:"components-upload-demo-upload-with-aliyun-oss"},previewerProps:{title:"Aliyun OSS",filename:"components/upload/demo/upload-with-aliyun-oss.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useEffect, useState } from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Form, message, Upload } from 'antd';
|
|
const AliyunOSSUpload = ({ value, onChange }) => {
|
|
const [OSSData, setOSSData] = useState();
|
|
|
|
// Mock get OSS api
|
|
// https://help.aliyun.com/document_detail/31988.html
|
|
const mockGetOSSData = () => ({
|
|
dir: 'user-dir/',
|
|
expire: '1577811661',
|
|
host: '//www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
accessId: 'c2hhb2RhaG9uZw==',
|
|
policy: 'eGl4aWhhaGFrdWt1ZGFkYQ==',
|
|
signature: 'ZGFob25nc2hhbw==',
|
|
});
|
|
const init = async () => {
|
|
try {
|
|
const result = await mockGetOSSData();
|
|
setOSSData(result);
|
|
} catch (error) {
|
|
message.error(error);
|
|
}
|
|
};
|
|
useEffect(() => {
|
|
init();
|
|
}, []);
|
|
const handleChange = ({ fileList }) => {
|
|
console.log('Aliyun OSS:', fileList);
|
|
onChange?.([...fileList]);
|
|
};
|
|
const onRemove = (file) => {
|
|
const files = (value || []).filter((v) => v.url !== file.url);
|
|
if (onChange) {
|
|
onChange(files);
|
|
}
|
|
};
|
|
const getExtraData = (file) => ({
|
|
key: file.url,
|
|
OSSAccessKeyId: OSSData?.accessId,
|
|
policy: OSSData?.policy,
|
|
Signature: OSSData?.signature,
|
|
});
|
|
const beforeUpload = async (file) => {
|
|
if (!OSSData) return false;
|
|
const expire = Number(OSSData.expire) * 1000;
|
|
if (expire < Date.now()) {
|
|
await init();
|
|
}
|
|
const suffix = file.name.slice(file.name.lastIndexOf('.'));
|
|
const filename = Date.now() + suffix;
|
|
// @ts-ignore
|
|
file.url = OSSData.dir + filename;
|
|
return file;
|
|
};
|
|
const uploadProps = {
|
|
name: 'file',
|
|
fileList: value,
|
|
action: OSSData?.host,
|
|
onChange: handleChange,
|
|
onRemove,
|
|
data: getExtraData,
|
|
beforeUpload,
|
|
};
|
|
return (
|
|
<Upload {...uploadProps}>
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
|
</Upload>
|
|
);
|
|
};
|
|
const App = () => (
|
|
<Form
|
|
labelCol={{
|
|
span: 4,
|
|
}}
|
|
>
|
|
<Form.Item label="Photos" name="photos">
|
|
<AliyunOSSUpload />
|
|
</Form.Item>
|
|
</Form>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Use Aliyun OSS upload example.</p>"}},{demo:{id:"components-upload-demo-file-type"},previewerProps:{debug:!0,title:"custom show icon",filename:"components/upload/demo/file-type.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React, { useState } from 'react';
|
|
import {
|
|
FileExcelTwoTone,
|
|
FilePdfTwoTone,
|
|
FileWordTwoTone,
|
|
LoadingOutlined,
|
|
PaperClipOutlined,
|
|
PictureTwoTone,
|
|
PlusOutlined,
|
|
} from '@ant-design/icons';
|
|
import { Modal, Upload } from 'antd';
|
|
const getBase64 = (file) =>
|
|
new Promise((resolve, reject) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.onload = () => resolve(reader.result);
|
|
reader.onerror = (error) => reject(error);
|
|
});
|
|
const App = () => {
|
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
const [previewImage, setPreviewImage] = useState('');
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-2',
|
|
name: 'pdf.pdf',
|
|
status: 'done',
|
|
url: 'http://cdn07.foxitsoftware.cn/pub/foxit/cpdf/FoxitCompanyProfile.pdf',
|
|
},
|
|
{
|
|
uid: '-3',
|
|
name: 'doc.doc',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.doc',
|
|
},
|
|
{
|
|
uid: '-4',
|
|
name: 'image.png',
|
|
status: 'error',
|
|
},
|
|
{
|
|
uid: '-5',
|
|
name: 'pdf.pdf',
|
|
status: 'error',
|
|
},
|
|
{
|
|
uid: '-6',
|
|
name: 'doc.doc',
|
|
status: 'error',
|
|
},
|
|
]);
|
|
const handleCancel = () => setPreviewOpen(false);
|
|
const handlePreview = async (file) => {
|
|
if (!file.url && !file.preview) {
|
|
file.preview = await getBase64(file.originFileObj);
|
|
}
|
|
setPreviewOpen(true);
|
|
setPreviewImage(file.url || file.preview);
|
|
};
|
|
const handleChange = ({ fileList: newFileList }) => setFileList(newFileList);
|
|
const handleIconRender = (file, listType) => {
|
|
const fileSufIconList = [
|
|
{
|
|
type: <FilePdfTwoTone />,
|
|
suf: ['.pdf'],
|
|
},
|
|
{
|
|
type: <FileExcelTwoTone />,
|
|
suf: ['.xlsx', '.xls', '.csv'],
|
|
},
|
|
{
|
|
type: <FileWordTwoTone />,
|
|
suf: ['.doc', '.docx'],
|
|
},
|
|
{
|
|
type: <PictureTwoTone />,
|
|
suf: ['.webp', '.svg', '.png', '.gif', '.jpg', '.jpeg', '.jfif', '.bmp', '.dpg'],
|
|
},
|
|
];
|
|
// console.log(1, file, listType);
|
|
let icon = file.status === 'uploading' ? <LoadingOutlined /> : <PaperClipOutlined />;
|
|
if (listType === 'picture' || listType === 'picture-card' || listType === 'picture-circle') {
|
|
if (listType === 'picture-card' && file.status === 'uploading') {
|
|
icon = <LoadingOutlined />; // or icon = 'uploading...';
|
|
} else {
|
|
fileSufIconList.forEach((item) => {
|
|
if (item.suf.includes(file.name.slice(file.name.lastIndexOf('.')))) {
|
|
icon = item.type;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
return icon;
|
|
};
|
|
const uploadButton = (
|
|
<div>
|
|
<PlusOutlined />
|
|
<div
|
|
style={{
|
|
marginTop: 8,
|
|
}}
|
|
>
|
|
Upload
|
|
</div>
|
|
</div>
|
|
);
|
|
return (
|
|
<>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture-card"
|
|
fileList={fileList}
|
|
onPreview={handlePreview}
|
|
onChange={handleChange}
|
|
iconRender={handleIconRender}
|
|
>
|
|
{fileList.length >= 8 ? null : uploadButton}
|
|
</Upload>
|
|
<Modal open={previewOpen} footer={null} onCancel={handleCancel}>
|
|
<img
|
|
alt="example"
|
|
style={{
|
|
width: '100%',
|
|
}}
|
|
src={previewImage}
|
|
/>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:"<p>Displays the corresponding by default by type icon</p>"}},{demo:{id:"components-upload-demo-upload-custom-action-icon"},previewerProps:{title:"custom action icon",filename:"components/upload/demo/upload-custom-action-icon.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { StarOutlined, UploadOutlined } from '@ant-design/icons';
|
|
import { Button, Upload } from 'antd';
|
|
const props = {
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
onChange({ file, fileList }) {
|
|
if (file.status !== 'uploading') {
|
|
console.log(file, fileList);
|
|
}
|
|
},
|
|
defaultFileList: [
|
|
{
|
|
uid: '1',
|
|
name: 'xxx.png',
|
|
status: 'done',
|
|
response: 'Server Error 500',
|
|
// custom error message to show
|
|
url: 'http://www.baidu.com/xxx.png',
|
|
},
|
|
{
|
|
uid: '2',
|
|
name: 'yyy.png',
|
|
status: 'done',
|
|
url: 'http://www.baidu.com/yyy.png',
|
|
},
|
|
{
|
|
uid: '3',
|
|
name: 'zzz.png',
|
|
status: 'error',
|
|
response: 'Server Error 500',
|
|
// custom error message to show
|
|
url: 'http://www.baidu.com/zzz.png',
|
|
},
|
|
],
|
|
showUploadList: {
|
|
showDownloadIcon: true,
|
|
downloadIcon: 'Download',
|
|
showRemoveIcon: true,
|
|
removeIcon: <StarOutlined onClick={(e) => console.log(e, 'custom removeIcon event')} />,
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Use <code>showUploadList</code> for custom action icons of files.</p>"}},{demo:{id:"components-upload-demo-drag-sorting"},previewerProps:{title:"Drag sorting of uploadList",filename:"components/upload/demo/drag-sorting.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import { UploadOutlined } from '@ant-design/icons';
|
|
import { DndContext, PointerSensor, useSensor } from '@dnd-kit/core';
|
|
import {
|
|
arrayMove,
|
|
SortableContext,
|
|
useSortable,
|
|
verticalListSortingStrategy,
|
|
} from '@dnd-kit/sortable';
|
|
import { CSS } from '@dnd-kit/utilities';
|
|
import { css } from '@emotion/css';
|
|
import { Button, Upload } from 'antd';
|
|
import React, { useState } from 'react';
|
|
const DraggableUploadListItem = ({ originNode, file }) => {
|
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
id: file.uid,
|
|
});
|
|
const style = {
|
|
transform: CSS.Transform.toString(transform),
|
|
transition,
|
|
cursor: 'move',
|
|
};
|
|
|
|
// prevent preview event when drag end
|
|
const className = isDragging
|
|
? css\`
|
|
a {
|
|
pointer-events: none;
|
|
}
|
|
\`
|
|
: '';
|
|
return (
|
|
<div ref={setNodeRef} style={style} className={className} {...attributes} {...listeners}>
|
|
{/* hide error tooltip when dragging */}
|
|
{file.status === 'error' && isDragging ? originNode.props.children : originNode}
|
|
</div>
|
|
);
|
|
};
|
|
const App = () => {
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-1',
|
|
name: 'image1.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-2',
|
|
name: 'image2.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-3',
|
|
name: 'image3.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-4',
|
|
name: 'image4.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
{
|
|
uid: '-5',
|
|
name: 'image.png',
|
|
status: 'error',
|
|
},
|
|
]);
|
|
const sensor = useSensor(PointerSensor, {
|
|
activationConstraint: {
|
|
distance: 10,
|
|
},
|
|
});
|
|
const onDragEnd = ({ active, over }) => {
|
|
if (active.id !== over?.id) {
|
|
setFileList((prev) => {
|
|
const activeIndex = prev.findIndex((i) => i.uid === active.id);
|
|
const overIndex = prev.findIndex((i) => i.uid === over?.id);
|
|
return arrayMove(prev, activeIndex, overIndex);
|
|
});
|
|
}
|
|
};
|
|
const onChange = ({ fileList: newFileList }) => {
|
|
setFileList(newFileList);
|
|
};
|
|
return (
|
|
<DndContext sensors={[sensor]} onDragEnd={onDragEnd}>
|
|
<SortableContext items={fileList.map((i) => i.uid)} strategy={verticalListSortingStrategy}>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
fileList={fileList}
|
|
onChange={onChange}
|
|
itemRender={(originNode, file) => (
|
|
<DraggableUploadListItem originNode={originNode} file={file} />
|
|
)}
|
|
>
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
|
</Upload>
|
|
</SortableContext>
|
|
</DndContext>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:'<p>By using <code>itemRender</code>, we can integrate upload with <a href="https://github.com/clauderic/dnd-kit">dnd-kit</a> to implement drag sorting of uploadList.</p>'}},{demo:{id:"components-upload-demo-crop-image"},previewerProps:{title:"Crop image before uploading",filename:"components/upload/demo/crop-image.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import { Upload } from 'antd';
|
|
import ImgCrop from 'antd-img-crop';
|
|
import React, { useState } from 'react';
|
|
const App = () => {
|
|
const [fileList, setFileList] = useState([
|
|
{
|
|
uid: '-1',
|
|
name: 'image.png',
|
|
status: 'done',
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
},
|
|
]);
|
|
const onChange = ({ fileList: newFileList }) => {
|
|
setFileList(newFileList);
|
|
};
|
|
const onPreview = async (file) => {
|
|
let src = file.url;
|
|
if (!src) {
|
|
src = await new Promise((resolve) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file.originFileObj);
|
|
reader.onload = () => resolve(reader.result);
|
|
});
|
|
}
|
|
const image = new Image();
|
|
image.src = src;
|
|
const imgWindow = window.open(src);
|
|
imgWindow?.document.write(image.outerHTML);
|
|
};
|
|
return (
|
|
<ImgCrop rotationSlider>
|
|
<Upload
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
listType="picture-card"
|
|
fileList={fileList}
|
|
onChange={onChange}
|
|
onPreview={onPreview}
|
|
>
|
|
{fileList.length < 5 && '+ Upload'}
|
|
</Upload>
|
|
</ImgCrop>
|
|
);
|
|
};
|
|
export default App;
|
|
`,description:'<p>Use <a href="https://github.com/nanxiaobei/antd-img-crop">antd-img-crop</a> to crop image before uploading.</p>'}},{demo:{id:"components-upload-demo-customize-progress-bar"},previewerProps:{title:"Customize Progress Bar",filename:"components/upload/demo/customize-progress-bar.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, message, Upload } from 'antd';
|
|
const props = {
|
|
name: 'file',
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
headers: {
|
|
authorization: 'authorization-text',
|
|
},
|
|
onChange(info) {
|
|
if (info.file.status !== 'uploading') {
|
|
console.log(info.file, info.fileList);
|
|
}
|
|
if (info.file.status === 'done') {
|
|
message.success(\`\${info.file.name} file uploaded successfully\`);
|
|
} else if (info.file.status === 'error') {
|
|
message.error(\`\${info.file.name} file upload failed.\`);
|
|
}
|
|
},
|
|
progress: {
|
|
strokeColor: {
|
|
'0%': '#108ee9',
|
|
'100%': '#87d068',
|
|
},
|
|
strokeWidth: 3,
|
|
format: (percent) => percent && \`\${parseFloat(percent.toFixed(2))}%\`,
|
|
},
|
|
};
|
|
const App = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
|
</Upload>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Use <code>progress</code> for customize progress bar.</p>"}},{demo:{id:"components-upload-demo-component-token"},previewerProps:{debug:!0,title:"Component Token",filename:"components/upload/demo/component-token.tsx",pkgDependencyList:{"@ant-design/colors":"^7.0.0","@ant-design/cssinjs":"^1.10.1","@ant-design/icons":"^5.1.0","@ant-design/react-slick":"~1.0.0","@babel/runtime":"^7.18.3","@ctrl/tinycolor":"^3.6.0","@rc-component/color-picker":"~1.4.0","@rc-component/mutate-observer":"^1.0.0","@rc-component/tour":"~1.8.0","@rc-component/trigger":"^1.13.0",classnames:"^2.2.6","copy-to-clipboard":"^3.2.0",dayjs:"^1.11.1","qrcode.react":"^3.1.0","rc-cascader":"~3.12.0","rc-checkbox":"~3.1.0","rc-collapse":"~3.7.0","rc-dialog":"~9.1.0","rc-drawer":"~6.2.0","rc-dropdown":"~4.1.0","rc-field-form":"~1.34.0","rc-image":"~7.0.0","rc-input":"~1.1.0","rc-input-number":"~8.0.2","rc-mentions":"~2.5.0","rc-menu":"~9.10.0","rc-motion":"^2.7.3","rc-notification":"~5.0.4","rc-pagination":"~3.5.0","rc-picker":"~3.10.0","rc-progress":"~3.4.1","rc-rate":"~2.12.0","rc-resize-observer":"^1.2.0","rc-segmented":"~2.2.0","rc-select":"~14.5.0","rc-slider":"~10.1.0","rc-steps":"~6.0.0","rc-switch":"~4.1.0","rc-table":"~7.32.1","rc-tabs":"~12.9.0","rc-textarea":"~1.3.2","rc-tooltip":"~6.0.0","rc-tree":"~5.7.6","rc-tree-select":"~5.9.0","rc-upload":"~4.3.0","rc-util":"^5.32.0","scroll-into-view-if-needed":"^3.0.3","throttle-debounce":"^5.0.0"},jsx:`import { UploadOutlined } from '@ant-design/icons';
|
|
import { Button, ConfigProvider, Upload } from 'antd';
|
|
import React from 'react';
|
|
const props = {
|
|
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
|
|
onChange({ file, fileList }) {
|
|
if (file.status !== 'uploading') {
|
|
console.log(file, fileList);
|
|
}
|
|
},
|
|
defaultFileList: [
|
|
{
|
|
uid: '1',
|
|
name: 'xxx.png',
|
|
status: 'uploading',
|
|
url: 'http://www.baidu.com/xxx.png',
|
|
percent: 33,
|
|
},
|
|
{
|
|
uid: '2',
|
|
name: 'yyy.png',
|
|
status: 'done',
|
|
url: 'http://www.baidu.com/yyy.png',
|
|
},
|
|
{
|
|
uid: '3',
|
|
name: 'zzz.png',
|
|
status: 'error',
|
|
response: 'Server Error 500',
|
|
// custom error message to show
|
|
url: 'http://www.baidu.com/zzz.png',
|
|
},
|
|
],
|
|
};
|
|
const App = () => (
|
|
<ConfigProvider
|
|
theme={{
|
|
components: {
|
|
Upload: {
|
|
actionsColor: 'yellow',
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
</ConfigProvider>
|
|
);
|
|
export default App;
|
|
`,description:"<p>Component Token Debug.</p>"}}]}),(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("h2",{id:"api"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#api",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"API"),(0,e.tZ)(i.Z,{className:"component-api-table"},(0,e.tZ)("thead",null,(0,e.tZ)("tr",null,(0,e.tZ)("th",null,n[5].value),(0,e.tZ)("th",null,n[6].value),(0,e.tZ)("th",null,n[7].value),(0,e.tZ)("th",null,n[8].value),(0,e.tZ)("th",null,n[9].value))),(0,e.tZ)("tbody",null,(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[10].value),(0,e.tZ)("td",null,n[11].value,(0,e.tZ)(o.Z,{href:"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept",sourceType:"a"},n[12].value)),(0,e.tZ)("td",null,n[13].value),(0,e.tZ)("td",null,n[14].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[15].value),(0,e.tZ)("td",null,n[16].value),(0,e.tZ)("td",null,n[17].value),(0,e.tZ)("td",null,n[18].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[19].value),(0,e.tZ)("td",null,n[20].value,(0,e.tZ)("code",null,n[21].value),n[22].value,(0,e.tZ)("code",null,n[23].value),n[24].value,(0,e.tZ)("strong",null,n[25].value)),(0,e.tZ)("td",null,n[26].value,(0,e.tZ)("code",null,n[27].value)),(0,e.tZ)("td",null,n[28].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[29].value),(0,e.tZ)("td",null,n[30].value),(0,e.tZ)("td",null,n[31].value),(0,e.tZ)("td",null,n[32].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[33].value),(0,e.tZ)("td",null,n[34].value),(0,e.tZ)("td",null,n[35].value),(0,e.tZ)("td",null,n[36].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[37].value),(0,e.tZ)("td",null,n[38].value),(0,e.tZ)("td",null,n[39].value),(0,e.tZ)("td",null,n[40].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[41].value),(0,e.tZ)("td",null,n[42].value,(0,e.tZ)(o.Z,{href:"https://caniuse.com/#feat=input-file-directory",sourceType:"a"},n[43].value),n[44].value),(0,e.tZ)("td",null,n[45].value),(0,e.tZ)("td",null,n[46].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[47].value),(0,e.tZ)("td",null,n[48].value),(0,e.tZ)("td",null,n[49].value),(0,e.tZ)("td",null,n[50].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[51].value),(0,e.tZ)("td",null,n[52].value,(0,e.tZ)(o.Z,{href:"https://github.com/ant-design/ant-design/issues/2423",sourceType:"a"},n[53].value),n[54].value),(0,e.tZ)("td",null,(0,e.tZ)(o.Z,{to:"#uploadfile",sourceType:"Link"},n[55].value),n[56].value),(0,e.tZ)("td",null,n[57].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[58].value),(0,e.tZ)("td",null,n[59].value),(0,e.tZ)("td",null,n[60].value),(0,e.tZ)("td",null,n[61].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[62].value),(0,e.tZ)("td",null,n[63].value),(0,e.tZ)("td",null,n[64].value),(0,e.tZ)("td",null,n[65].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[66].value),(0,e.tZ)("td",null,n[67].value),(0,e.tZ)("td",null,n[68].value),(0,e.tZ)("td",null,(0,e.tZ)(o.Z,{href:"https://github.com/ant-design/ant-design/blob/4ad5830eecfb87471cd8ac588c5d992862b70770/components/upload/utils.tsx#L47-L68",sourceType:"a"},n[69].value)),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[70].value),(0,e.tZ)("td",null,n[71].value),(0,e.tZ)("td",null,n[72].value),(0,e.tZ)("td",null,n[73].value),(0,e.tZ)("td",null,n[74].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[75].value),(0,e.tZ)("td",null,n[76].value,(0,e.tZ)("code",null,n[77].value),n[78].value,(0,e.tZ)("code",null,n[79].value),n[80].value,(0,e.tZ)("code",null,n[81].value),n[82].value,(0,e.tZ)("code",null,n[83].value)),(0,e.tZ)("td",null,n[84].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[85].value)),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[86].value),n[87].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[88].value),(0,e.tZ)("td",null,n[89].value,(0,e.tZ)("code",null,n[90].value),n[91].value,(0,e.tZ)("code",null,n[92].value)),(0,e.tZ)("td",null,n[93].value),(0,e.tZ)("td",null,n[94].value),(0,e.tZ)("td",null,n[95].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[96].value),(0,e.tZ)("td",null,n[97].value),(0,e.tZ)("td",null,n[98].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[99].value)),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[100].value),(0,e.tZ)("td",null,n[101].value,(0,e.tZ)("code",null,n[102].value),n[103].value),(0,e.tZ)("td",null,n[104].value),(0,e.tZ)("td",null,n[105].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[106].value),(0,e.tZ)("td",null,n[107].value),(0,e.tZ)("td",null,n[108].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[109].value)),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[110].value),(0,e.tZ)("td",null,n[111].value),(0,e.tZ)("td",null,n[112].value),(0,e.tZ)("td",null,n[113].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[114].value),(0,e.tZ)("td",null,n[115].value),(0,e.tZ)("td",null,n[116].value),(0,e.tZ)("td",null,n[117].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[118].value),(0,e.tZ)("td",null,n[119].value),(0,e.tZ)("td",null,(0,e.tZ)(o.Z,{to:"/components/progress/#api",sourceType:"Link"},n[120].value),n[121].value,(0,e.tZ)("code",null,n[122].value),n[123].value),(0,e.tZ)("td",null,n[124].value),(0,e.tZ)("td",null,n[125].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[126].value),(0,e.tZ)("td",null,n[127].value,(0,e.tZ)("code",null,n[128].value),n[129].value,(0,e.tZ)("code",null,n[130].value),n[131].value,(0,e.tZ)("code",null,n[132].value),n[133].value,(0,e.tZ)("code",null,n[134].value),n[135].value,(0,e.tZ)("code",null,n[136].value),n[137].value),(0,e.tZ)("td",null,n[138].value),(0,e.tZ)("td",null,n[139].value),(0,e.tZ)("td",null,n[140].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[141].value),(0,e.tZ)("td",null,n[142].value),(0,e.tZ)("td",null,n[143].value),(0,e.tZ)("td",null,n[144].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[145].value),(0,e.tZ)("td",null,n[146].value,(0,e.tZ)(o.Z,{to:"#onchange",sourceType:"Link"},n[147].value)),(0,e.tZ)("td",null,n[148].value),(0,e.tZ)("td",null,n[149].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[150].value),(0,e.tZ)("td",null,n[151].value),(0,e.tZ)("td",null,n[152].value),(0,e.tZ)("td",null,n[153].value),(0,e.tZ)("td",null,n[154].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[155].value),(0,e.tZ)("td",null,n[156].value),(0,e.tZ)("td",null,n[157].value),(0,e.tZ)("td",null,n[158].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[159].value),(0,e.tZ)("td",null,n[160].value),(0,e.tZ)("td",null,n[161].value),(0,e.tZ)("td",null,n[162].value),(0,e.tZ)("td",null)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[163].value),(0,e.tZ)("td",null,n[164].value),(0,e.tZ)("td",null,n[165].value),(0,e.tZ)("td",null,n[166].value),(0,e.tZ)("td",null)))),(0,e.tZ)("h3",{id:"uploadfile"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#uploadfile",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"UploadFile"),(0,e.tZ)("p",null,n[167].value),(0,e.tZ)(i.Z,{className:"component-api-table"},(0,e.tZ)("thead",null,(0,e.tZ)("tr",null,(0,e.tZ)("th",null,n[168].value),(0,e.tZ)("th",null,n[169].value),(0,e.tZ)("th",null,n[170].value),(0,e.tZ)("th",null,n[171].value),(0,e.tZ)("th",null,n[172].value))),(0,e.tZ)("tbody",null,(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[173].value),(0,e.tZ)("td",null,n[174].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[175].value),n[176].value,(0,e.tZ)("code",null,n[177].value),n[178].value,(0,e.tZ)("code",null,n[179].value)),(0,e.tZ)("td",null,n[180].value),(0,e.tZ)("td",null,n[181].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[182].value),(0,e.tZ)("td",null,n[183].value),(0,e.tZ)("td",null,n[184].value),(0,e.tZ)("td",null,n[185].value),(0,e.tZ)("td",null,n[186].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[187].value),(0,e.tZ)("td",null,n[188].value),(0,e.tZ)("td",null,n[189].value),(0,e.tZ)("td",null,n[190].value),(0,e.tZ)("td",null,n[191].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[192].value),(0,e.tZ)("td",null,n[193].value),(0,e.tZ)("td",null,(0,e.tZ)("code",null,n[194].value),n[195].value,(0,e.tZ)("code",null,n[196].value),n[197].value,(0,e.tZ)("code",null,n[198].value),n[199].value,(0,e.tZ)("code",null,n[200].value),n[201].value,(0,e.tZ)("code",null,n[202].value)),(0,e.tZ)("td",null,n[203].value),(0,e.tZ)("td",null,n[204].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[205].value),(0,e.tZ)("td",null,n[206].value),(0,e.tZ)("td",null,n[207].value),(0,e.tZ)("td",null,n[208].value),(0,e.tZ)("td",null,n[209].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[210].value),(0,e.tZ)("td",null,n[211].value),(0,e.tZ)("td",null,n[212].value),(0,e.tZ)("td",null,n[213].value),(0,e.tZ)("td",null,n[214].value)),(0,e.tZ)("tr",null,(0,e.tZ)("td",null,n[215].value),(0,e.tZ)("td",null,n[216].value),(0,e.tZ)("td",null,n[217].value),(0,e.tZ)("td",null,n[218].value),(0,e.tZ)("td",null,n[219].value)))),(0,e.tZ)("h3",{id:"onchange"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#onchange",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"onChange"),(0,e.tZ)("blockquote",null,(0,e.tZ)("p",null,n[220].value)),(0,e.tZ)("p",null,n[221].value),(0,e.tZ)(l.Z,{lang:"js"},n[222].value),(0,e.tZ)("ol",null,(0,e.tZ)("li",null,(0,e.tZ)("p",null,(0,e.tZ)("code",null,n[223].value),n[224].value),(0,e.tZ)(l.Z,{lang:"js"},n[225].value)),(0,e.tZ)("li",null,(0,e.tZ)("p",null,(0,e.tZ)("code",null,n[226].value),n[227].value)),(0,e.tZ)("li",null,(0,e.tZ)("p",null,(0,e.tZ)("code",null,n[228].value),n[229].value))),(0,e.tZ)("h2",{id:"design-token"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#design-token",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Design Token")),(0,e.tZ)(c.Z,{component:"Upload"}),(0,e.tZ)("div",{className:"markdown"},(0,e.tZ)("h2",{id:"faq"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#faq",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"FAQ"),(0,e.tZ)("h3",{id:"how-do-i-implement-upload-server-side"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#how-do-i-implement-upload-server-side",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"How do I implement upload server side?"),(0,e.tZ)("ul",null,(0,e.tZ)("li",null,n[230].value,(0,e.tZ)(o.Z,{href:"https://github.com/blueimp/jQuery-File-Upload/wiki#server-side",sourceType:"a"},n[231].value),n[232].value),(0,e.tZ)("li",null,n[233].value,(0,e.tZ)(o.Z,{href:"https://github.com/react-component/upload/blob/master/server.js",sourceType:"a"},n[234].value),n[235].value)),(0,e.tZ)("h3",{id:"i-want-to-display-download-links"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#i-want-to-display-download-links",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"I want to display download links."),(0,e.tZ)("p",null,n[236].value,(0,e.tZ)("code",null,n[237].value),n[238].value,(0,e.tZ)("code",null,n[239].value),n[240].value),(0,e.tZ)("h3",{id:"how-to-use-customrequest"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#how-to-use-customrequest",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"How to use ",(0,e.tZ)("code",null,n[241].value),"?"),(0,e.tZ)("p",null,n[242].value,(0,e.tZ)(o.Z,{href:"https://github.com/react-component/upload#customrequest",sourceType:"a"},n[243].value),n[244].value),(0,e.tZ)("h3",{id:"why-will-the-filelist-thats-in-control-not-trigger-onchange-status-update-when-the-file-is-not-in-the-list"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#why-will-the-filelist-thats-in-control-not-trigger-onchange-status-update-when-the-file-is-not-in-the-list",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Why will the ",(0,e.tZ)("code",null,n[245].value)," that's in control not trigger ",(0,e.tZ)("code",null,n[246].value)," ",(0,e.tZ)("code",null,n[247].value)," update when the file is not in the list?"),(0,e.tZ)("p",null,(0,e.tZ)("code",null,n[248].value),n[249].value,(0,e.tZ)("code",null,n[250].value),n[251].value),(0,e.tZ)("h3",{id:"why-does-onchange-sometimes-return-file-object-and-other-times-return--originfileobj-file-"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#why-does-onchange-sometimes-return-file-object-and-other-times-return--originfileobj-file-",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Why does ",(0,e.tZ)("code",null,n[252].value)," sometimes return File object and other times return { originFileObj: File }?"),(0,e.tZ)("p",null,n[253].value,(0,e.tZ)("code",null,n[254].value),n[255].value,(0,e.tZ)("code",null,n[256].value),n[257].value,(0,e.tZ)("code",null,n[258].value),n[259].value,(0,e.tZ)("code",null,n[260].value),n[261].value),(0,e.tZ)("h3",{id:"why-sometimes-chrome-can-not-upload"},(0,e.tZ)(o.Z,{"aria-hidden":"true",tabIndex:"-1",href:"#why-sometimes-chrome-can-not-upload",sourceType:"a"},(0,e.tZ)("span",{className:"icon icon-link"})),"Why sometimes Chrome can not upload?"),(0,e.tZ)("p",null,n[262].value),(0,e.tZ)("ul",null,(0,e.tZ)("li",null,(0,e.tZ)(o.Z,{href:"https://github.com/ant-design/ant-design/issues/32672",sourceType:"a"},n[263].value)),(0,e.tZ)("li",null,(0,e.tZ)(o.Z,{href:"https://github.com/ant-design/ant-design/issues/32913",sourceType:"a"},n[264].value)),(0,e.tZ)("li",null,(0,e.tZ)(o.Z,{href:"https://github.com/ant-design/ant-design/issues/33988",sourceType:"a"},n[265].value))))))}r.default=u}}]);
|
|
|