syncfusion-react-uploader
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion React Uploader
实现Syncfusion React Uploader
The Syncfusion React UploaderComponent provides a rich file upload control with async upload, drag-and-drop, chunk upload with pause/resume/cancel, validation, templates, form integration, and accessibility support.
Syncfusion React UploaderComponent 提供了功能丰富的文件上传控件,支持异步上传、拖拽上传、带暂停/恢复/取消功能的分片上传、校验、模板、表单集成以及无障碍访问支持。
Navigation Guide
导航指南
Getting Started
入门
📄 Read: references/getting-started.md
- Installation and package setup for React
- License registration
- Basic usage in JSX/TSX
UploaderComponent - CSS theme imports
- Drop area configuration
- Success and failure event handling
📄 阅读: references/getting-started.md
- React 安装与包配置
- 许可证注册
- JSX/TSX 中 的基础用法
UploaderComponent - CSS 主题导入
- 拖拽区域配置
- 成功与失败事件处理
Asynchronous Upload
异步上传
📄 Read: references/async-upload.md
- with
asyncSettingsandsaveUrlremoveUrl - Multiple vs. single file upload ()
multiple - Auto upload vs. manual upload ()
autoUpload - Sequential upload ()
sequentialUpload - Preloaded files (property)
files - Adding custom HTTP headers via /
uploadingeventsremoving - Server-side save/remove action examples
📄 阅读: references/async-upload.md
- 配置带 和
saveUrl的removeUrlasyncSettings - 多文件 vs 单文件上传()
multiple - 自动上传 vs 手动上传()
autoUpload - 顺序上传()
sequentialUpload - 预加载文件(属性)
files - 通过 /
uploading事件添加自定义 HTTP 头removing - 服务端保存/删除操作示例
Chunk Upload
分片上传
📄 Read: references/chunk-upload.md
- Enabling chunk upload with
asyncSettings.chunkSize - Retry configuration (,
retryCount)retryAfterDelay - Pause and resume chunked uploads (,
pausemethods)resume - Cancel uploads (method)
cancel - and
chunkSuccesseventschunkFailure - Server-side chunk handling (C#)
📄 阅读: references/chunk-upload.md
- 通过 启用分片上传
asyncSettings.chunkSize - 重试配置(、
retryCount)retryAfterDelay - 暂停和恢复分片上传(、
pause方法)resume - 取消上传(方法)
cancel - 和
chunkSuccess事件chunkFailure - 服务端分片处理(C#)
Validation
校验
📄 Read: references/validation.md
- Allowed file extensions ()
allowedExtensions - File size limits (,
minFileSize)maxFileSize - Maximum file count using event
selected - Duplicate file prevention
- Drag-and-drop image validation
📄 阅读: references/validation.md
- 允许的文件扩展名()
allowedExtensions - 文件大小限制(、
minFileSize)maxFileSize - 通过 事件限制最大文件数量
selected - 重复文件拦截
- 拖拽图片校验
File Sources
文件来源
📄 Read: references/file-source.md
- Clipboard paste upload
- Directory/folder upload ()
directoryUpload - Drag-and-drop with custom drop area ()
dropArea - Customizing drop area appearance
📄 阅读: references/file-source.md
- 剪贴板粘贴上传
- 目录/文件夹上传()
directoryUpload - 自定义拖拽区域的拖拽上传()
dropArea - 自定义拖拽区域外观
Templates and Customization
模板与自定义
📄 Read: references/template-customization.md
- File list property
template - Custom upload UI with
showFileList: false - Customizing action buttons (property)
buttons - Progress bar customization
- Hiding the default drop area
- Style and appearance overrides
📄 阅读: references/template-customization.md
- 文件列表 属性
template - 配置 实现自定义上传UI
showFileList: false - 自定义操作按钮(属性)
buttons - 进度条自定义
- 隐藏默认拖拽区域
- 样式与外观覆盖
Advanced How-To Scenarios
高级场景指南
📄 Read: references/advanced-how-to.md
- Programmatic file upload (method,
upload)getFilesData - Invisible/background upload
- Image preview before uploading
- Resize images before upload
- Sort selected files
- Check file size / MIME type before upload
- Confirm dialog before file removal
- Open/edit uploaded files
- Trigger file browser from external button
- Convert uploaded image to binary
- JWT authentication for secure upload
- Form support (HTML form, template-driven, reactive)
- Localization (custom locale strings)
- Accessibility and keyboard navigation
📄 阅读: references/advanced-how-to.md
- 程序化文件上传(方法、
upload)getFilesData - 隐式/后台上传
- 上传前图片预览
- 上传前图片压缩
- 已选文件排序
- 上传前检查文件大小/MIME类型
- 文件删除前确认弹窗
- 打开/编辑已上传文件
- 从外部按钮触发文件浏览器
- 已上传图片转二进制
- JWT 认证实现安全上传
- 表单支持(HTML表单、模板驱动表单、响应式表单)
- 本地化(自定义 locale 字符串)
- 无障碍访问与键盘导航
API Reference
API 参考
📄 Read: references/api.md
- All properties (,
allowedExtensions,asyncSettings,autoUpload,buttons,cssClass,directoryUpload,dropArea,dropEffect,enabled,files,htmlAttributes,locale,maxFileSize,minFileSize,multiple,sequentialUpload,showFileList, and more)template - All methods (,
upload,remove,cancel,pause,resume,retry,clearAll,getFilesData,bytesToSize,createFileList)sortFileList - All events (,
uploading,success,failure,selected,removing,change,progress,chunkSuccess,chunkFailure,chunkUploading,actionComplete,beforeRemove,beforeUpload,canceling,clearing,fileListRendering,pausing,resuming)created
📄 阅读: references/api.md
- 所有属性(、
allowedExtensions、asyncSettings、autoUpload、buttons、cssClass、directoryUpload、dropArea、dropEffect、enabled、files、htmlAttributes、locale、maxFileSize、minFileSize、multiple、sequentialUpload、showFileList等)template - 所有方法(、
upload、remove、cancel、pause、resume、retry、clearAll、getFilesData、bytesToSize、createFileList)sortFileList - 所有事件(、
uploading、success、failure、selected、removing、change、progress、chunkSuccess、chunkFailure、chunkUploading、actionComplete、beforeRemove、beforeUpload、canceling、clearing、fileListRendering、pausing、resuming)created
Quick Start Example
快速入门示例
tsx
import { UploaderComponent } from '@syncfusion/ej2-react-inputs';
import '@syncfusion/ej2-base/styles/material.css';
import '@syncfusion/ej2-buttons/styles/material.css';
import '@syncfusion/ej2-inputs/styles/material.css';
import '@syncfusion/ej2-popups/styles/material.css';
import '@syncfusion/ej2-react-inputs/styles/material.css';
function App() {
const asyncSettings = {
saveUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Save',
removeUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Remove'
};
const onSuccess = (args: any) => {
console.log('Upload operation:', args.operation, 'File:', args.file.name);
};
const onFailure = (args: any) => {
console.error('Upload failed:', args.file.name);
};
return (
<UploaderComponent
asyncSettings={asyncSettings}
autoUpload={false}
success={onSuccess}
failure={onFailure}
/>
);
}tsx
import { UploaderComponent } from '@syncfusion/ej2-react-inputs';
import '@syncfusion/ej2-base/styles/material.css';
import '@syncfusion/ej2-buttons/styles/material.css';
import '@syncfusion/ej2-inputs/styles/material.css';
import '@syncfusion/ej2-popups/styles/material.css';
import '@syncfusion/ej2-react-inputs/styles/material.css';
function App() {
const asyncSettings = {
saveUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Save',
removeUrl: 'https://services.syncfusion.com/react/production/api/FileUploader/Remove'
};
const onSuccess = (args: any) => {
console.log('Upload operation:', args.operation, 'File:', args.file.name);
};
const onFailure = (args: any) => {
console.error('Upload failed:', args.file.name);
};
return (
<UploaderComponent
asyncSettings={asyncSettings}
autoUpload={false}
success={onSuccess}
failure={onFailure}
/>
);
}Common Patterns
常用模式
Auto Upload with Validation
带校验的自动上传
tsx
<UploaderComponent
asyncSettings={{ saveUrl: '/api/upload/save', removeUrl: '/api/upload/remove' }}
allowedExtensions=".pdf,.doc,.docx"
maxFileSize={5000000}
multiple={true}
/>tsx
<UploaderComponent
asyncSettings={{ saveUrl: '/api/upload/save', removeUrl: '/api/upload/remove' }}
allowedExtensions=".pdf,.doc,.docx"
maxFileSize={5000000}
multiple={true}
/>Manual Upload with Custom Buttons
带自定义按钮的手动上传
tsx
<UploaderComponent
asyncSettings={{ saveUrl: '/api/upload/save', removeUrl: '/api/upload/remove' }}
autoUpload={false}
buttons={{ browse: 'Choose File', clear: 'Clear All', upload: 'Upload All' }}
/>tsx
<UploaderComponent
asyncSettings={{ saveUrl: '/api/upload/save', removeUrl: '/api/upload/remove' }}
autoUpload={false}
buttons={{ browse: 'Choose File', clear: 'Clear All', upload: 'Upload All' }}
/>Chunk Upload for Large Files
大文件分片上传
tsx
<UploaderComponent
asyncSettings={{
saveUrl: '/api/upload/save',
removeUrl: '/api/upload/remove',
chunkSize: 500000 // 500 KB chunks
}}
/>tsx
<UploaderComponent
asyncSettings={{
saveUrl: '/api/upload/save',
removeUrl: '/api/upload/remove',
chunkSize: 500000 // 500 KB chunks
}}
/>Key Decision Guide
关键选型指南
| Need | Property/Event |
|---|---|
| Server URLs | |
| Auto vs manual upload | |
| Large file upload | |
| Restrict file types | |
| Limit file size | |
| Preload files from server | |
| Upload one at a time | |
| Entire folder upload | |
| Custom drop target | |
| Custom file list UI | |
| Add auth headers | |
| Send extra form data | |
| 需求 | 属性/事件 |
|---|---|
| 服务端URL | |
| 自动/手动上传 | |
| 大文件上传 | |
| 限制文件类型 | |
| 限制文件大小 | |
| 从服务端预加载文件 | |
| 单文件顺序上传 | |
| 整文件夹上传 | |
| 自定义拖拽目标 | |
| 自定义文件列表UI | |
| 添加认证头 | |
| 发送额外表单数据 | |