Loading...
Loading...
Compare original and translation side by side
| Feature | Use Case |
|---|---|
| Asynchronous Upload | Non-blocking uploads with SaveUrl/RemoveUrl handlers |
| Multiple File Upload | Select and upload many files at once |
| Single File Upload | Restrict to one file per selection |
| File Validation | Validate extensions, size, count, duplicates |
| Drag and Drop | Drop files directly onto uploader area |
| Custom Drop Area | Define external elements as drop zones |
| Auto Upload | Upload files automatically or manually |
| Progress Tracking | Display upload progress with progress bar |
| File Removal | Remove uploaded files with RemoveUrl handler |
| Chunk Upload | Break large files into chunks for reliable upload |
| Paste Upload | Upload images from clipboard |
| Directory Upload | Upload entire folders and directory structure |
| Form Integration | Submit files as part of form submission |
| Templates | Customize file list and button appearance |
| Localization | Support multiple languages and cultures |
| Error Handling | Display upload failures with custom messages |
| 特性 | 使用场景 |
|---|---|
| 异步上传 | 借助SaveUrl/RemoveUrl处理器实现无阻塞上传 |
| 多文件上传 | 一次性选择并上传多个文件 |
| 单文件上传 | 限制每次选择仅上传一个文件 |
| 文件验证 | 验证文件扩展名、大小、数量及重复文件 |
| 拖放功能 | 直接将文件拖放到上传区域 |
| 自定义拖放区域 | 将外部元素定义为拖放区 |
| 自动上传 | 自动或手动触发文件上传 |
| 进度跟踪 | 通过进度条显示上传进度 |
| 文件移除 | 借助RemoveUrl处理器移除已上传文件 |
| 分片上传 | 将大文件拆分为分片以实现可靠上传 |
| 粘贴上传 | 从剪贴板上传图片 |
| 目录上传 | 上传整个文件夹及目录结构 |
| 表单集成 | 将文件作为表单提交的一部分进行提交 |
| 模板定制 | 自定义文件列表和按钮外观 |
| 本地化 | 支持多种语言和区域文化 |
| 错误处理 | 显示上传失败信息并支持自定义提示 |
<ejs-scripts><ejs-scripts>multiplesequential-uploadauto-uploadsuccessfailureprogressargs.e.loaded / args.e.totaluploadingmultiplesequential-uploadauto-uploadsuccessfailureprogressargs.e.loaded / args.e.totaluploadingallowed-extensionsmin-file-sizemax-file-sizeselectedej.base.L10n.loadallowed-extensionsmin-file-sizemax-file-sizeselectedej.base.L10n.loaddrop-areaallowed-extensionsselecteddirectory-uploaddrop-areaallowed-extensionsselecteddirectory-uploadtemplate${name}${size}${type}${statusText}<e-upload-buttons browse="" upload="" clear="">show-file-listcss-classtemplate${name}${size}${type}${statusText}<e-upload-buttons browse="" upload="" clear="">show-file-listcss-classchunk-sizeretry-countretry-after-delaychunk-indextotal-chunkautoUpload="false"directory-uploadchunk-sizeretry-countretry-after-delaychunk-indextotal-chunkautoUpload="false"directory-upload<!-- Views/Home/Index.cshtml -->
<div class="form-group">
<ejs-uploader id="uploader">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
<e-upload-files></e-upload-files>
</ejs-uploader>
</div>
<div id="uploadedFiles"></div><!-- Views/Home/Index.cshtml -->
<div class="form-group">
<ejs-uploader id="uploader">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
<e-upload-files></e-upload-files>
</ejs-uploader>
</div>
<div id="uploadedFiles"></div>using Microsoft.AspNetCore.Mvc;
using System.IO;
public class HomeController : Controller
{
private readonly IWebHostEnvironment _webHostEnvironment;
public HomeController(IWebHostEnvironment webHostEnvironment)
{
_webHostEnvironment = webHostEnvironment;
}
[HttpPost]
public IActionResult Save(IFormFile[] uploader)
{
if (uploader != null && uploader.Length > 0)
{
string uploadPath = Path.Combine(_webHostEnvironment.WebRootPath, "Uploads");
if (!Directory.Exists(uploadPath))
Directory.CreateDirectory(uploadPath);
foreach (IFormFile file in uploader)
{
string filePath = Path.Combine(uploadPath, file.FileName);
using (FileStream fs = System.IO.File.Create(filePath))
{
file.CopyTo(fs);
fs.Flush();
}
}
}
return Ok();
}
[HttpPost]
public IActionResult Remove(string[] files)
{
string uploadPath = Path.Combine(_webHostEnvironment.WebRootPath, "Uploads");
foreach (string file in files)
{
string filePath = Path.Combine(uploadPath, file);
if (System.IO.File.Exists(filePath))
System.IO.File.Delete(filePath);
}
return Ok();
}
}using Microsoft.AspNetCore.Mvc;
using System.IO;
public class HomeController : Controller
{
private readonly IWebHostEnvironment _webHostEnvironment;
public HomeController(IWebHostEnvironment webHostEnvironment)
{
_webHostEnvironment = webHostEnvironment;
}
[HttpPost]
public IActionResult Save(IFormFile[] uploader)
{
if (uploader != null && uploader.Length > 0)
{
string uploadPath = Path.Combine(_webHostEnvironment.WebRootPath, "Uploads");
if (!Directory.Exists(uploadPath))
Directory.CreateDirectory(uploadPath);
foreach (IFormFile file in uploader)
{
string filePath = Path.Combine(uploadPath, file.FileName);
using (FileStream fs = System.IO.File.Create(filePath))
{
file.CopyTo(fs);
fs.Flush();
}
}
}
return Ok();
}
[HttpPost]
public IActionResult Remove(string[] files)
{
string uploadPath = Path.Combine(_webHostEnvironment.WebRootPath, "Uploads");
foreach (string file in files)
{
string filePath = Path.Combine(uploadPath, file);
if (System.IO.File.Exists(filePath))
System.IO.File.Delete(filePath);
}
return Ok();
}
}@addTagHelper *, Syncfusion.EJ2@addTagHelper *, Syncfusion.EJ2<head>
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/33.1.44/fluent.css" />
<script src="https://cdn.syncfusion.com/ej2/33.1.44/dist/ej2.min.js"></script>
</head>
<body>
@RenderBody()
<ejs-scripts></ejs-scripts>
</body><head>
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/33.1.44/fluent.css" />
<script src="https://cdn.syncfusion.com/ej2/33.1.44/dist/ej2.min.js"></script>
</head>
<body>
@RenderBody()
<ejs-scripts></ejs-scripts>
</body><ejs-uploader id="multiUploader"
allowedExtensions=".jpg,.png,.pdf,.doc,.docx"
maxFileSize="5242880"
autoUpload="false"
multiple="true"
progress="onProgress"
success="onSuccess"
failure="onFailure">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader>
<script>
function onProgress(args) {
console.log('Uploading: ' + args.file.name);
let percent = Math.round((args.e.loaded / args.e.total) * 100);
console.log('Progress: ' + percent + '%');
}
function onSuccess(args) {
if (args.operation === 'upload') {
console.log(args.file.name + ' uploaded successfully');
}
}
function onFailure(args) {
console.log('Upload failed: ' + args.statusCode + ' | ' + args.response);
}
</script><ejs-uploader id="multiUploader"
allowedExtensions=".jpg,.png,.pdf,.doc,.docx"
maxFileSize="5242880"
autoUpload="false"
multiple="true"
progress="onProgress"
success="onSuccess"
failure="onFailure">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader>
<script>
function onProgress(args) {
console.log('Uploading: ' + args.file.name);
let percent = Math.round((args.e.loaded / args.e.total) * 100);
console.log('Progress: ' + percent + '%');
}
function onSuccess(args) {
if (args.operation === 'upload') {
console.log(args.file.name + ' uploaded successfully');
}
}
function onFailure(args) {
console.log('Upload failed: ' + args.statusCode + ' | ' + args.response);
}
</script><ejs-uploader id="singleUploader"
allowedExtensions=".jpg,.png,.jpeg"
maxFileSize="2097152"
multiple="false"
selected="onFileSelected"
autoUpload="true">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader>
<script>
function onFileSelected(args) {
if (args.filesData.length > 1) {
args.filesData.splice(1);
alert('Only one file can be selected');
}
}
</script><ejs-uploader id="singleUploader"
allowedExtensions=".jpg,.png,.jpeg"
maxFileSize="2097152"
multiple="false"
selected="onFileSelected"
autoUpload="true">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader>
<script>
function onFileSelected(args) {
if (args.filesData.length > 1) {
args.filesData.splice(1);
alert('Only one file can be selected');
}
}
</script><div id="dropArea" style="border: 2px dashed #ccc; padding: 20px; min-height: 200px;">
Drop files here
</div>
<ejs-uploader id="uploader"
dropArea="#dropArea"
autoUpload="true">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader><div id="dropArea" style="border: 2px dashed #ccc; padding: 20px; min-height: 200px;">
Drop files here
</div>
<ejs-uploader id="uploader"
dropArea="#dropArea"
autoUpload="true">
<e-uploader-asyncsettings saveUrl="Home/Save" removeUrl="Home/Remove"></e-uploader-asyncsettings>
</ejs-uploader>| Property | TagHelper Attribute | Type | Default | Purpose |
|---|---|---|---|---|
| | string | | File types to allow (e.g., |
| | double | | Maximum file size in bytes |
| | double | | Minimum file size in bytes |
| | bool | | Allow multiple file selection |
| | bool | | Upload files automatically after selection |
| | bool | | Upload files one after another |
| | string | null | CSS selector for custom drop area |
| | bool | | Allow folder/directory selection |
| | bool | | Show/hide the default file list |
| | string | null | Custom HTML template for file list items |
| | string | | Additional CSS classes on root element |
| | bool | | Right-to-left rendering |
| | string | | Localization culture code |
<e-uploader-asyncsettings>| Property | TagHelper Attribute | Default | Purpose |
|---|---|---|---|
| | | Server endpoint for saving uploaded files |
| | | Server endpoint for removing uploaded files |
| | | Chunk size in bytes; enables chunk upload when > 0 |
| | | Number of retry attempts on chunk failure |
| | | Delay (ms) before chunk retry |
| 属性 | TagHelper属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|---|
| | string | | 允许的文件类型(例如: |
| | double | | 最大文件大小(字节) |
| | double | | 最小文件大小(字节) |
| | bool | | 是否允许选择多个文件 |
| | bool | | 文件选择后是否自动上传 |
| | bool | | 是否按顺序上传文件 |
| | string | null | 自定义拖放区域的CSS选择器 |
| | bool | | 是否允许选择文件夹/目录 |
| | bool | | 是否显示默认文件列表 |
| | string | null | 文件列表项的自定义HTML模板 |
| | string | | 根元素的额外CSS类 |
| | bool | | 是否启用从右到左渲染 |
| | string | | 本地化区域代码 |
<e-uploader-asyncsettings>| 属性 | TagHelper属性 | 默认值 | 用途 |
|---|---|---|---|
| | | 保存上传文件的服务端端点 |
| | | 移除已上传文件的服务端端点 |
| | | 分片大小(字节);大于0时启用分片上传 |
| | | 分片上传失败后的重试次数 |
| | | 分片重试前的延迟时间(毫秒) |