forked from syncfusion/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileValidation.razor
36 lines (30 loc) · 2.28 KB
/
FileValidation.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@page "/File-Upload/File-Validation"
@using Syncfusion.Blazor.Inputs
@inherits SampleBaseComponent;
<SampleDescription>
<p>This sample demonstrates how to validate the files before uploading it to server. Only document files (DOC, DOCX, XLS, XLSX), and the files should contain minimum 10 KB and maximum 4 MB sizes to upload it into server. This sample limits maximum files count as 5 to upload.</p>
</SampleDescription>
<ActionDescription>
<p>The Uploader component allows to validate the file’s type, and limit the file size using <a href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.UploaderModel.html#Syncfusion_Blazor_Inputs_UploaderModel_AllowedExtensions' target='_blank'> AllowedExtensions</a>, <a href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.UploaderModel.html#Syncfusion_Blazor_Inputs_UploaderModel_MinFileSize' target='_blank'> MinFileSize</a>, and <a href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.UploaderModel.html#Syncfusion_Blazor_Inputs_UploaderModel_MaxFileSize' target='_blank'> MaxFileSize</a> properties. You can also achieve limit the files count before uploading it using <a href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.UploaderEvents.html#Syncfusion_Blazor_Inputs_UploaderEvents_FileSelected' target='_blank'> FileSelected</a> event.</p>
<p>For more information, you can refer to the Validation section from this <a target='_blank' href='https://blazor.syncfusion.com/documentation/file-upload/validation/'> documentation section</a>.</p>
</ActionDescription>
<div class="col-lg-12 control-section">
<div class="control_wrapper">
<SfUploader ID="UploadFiles" DropArea=".control-fluid" AllowedExtensions=".doc, .docx, .xls, .xlsx" MinFileSize=10000 MaxFileSize=104857600>
<UploaderEvents OnRemove="OnFileRemove"></UploaderEvents>
<UploaderAsyncSettings SaveUrl="https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save" RemoveUrl="https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove"></UploaderAsyncSettings>
</SfUploader>
</div>
</div>
<style>
.control_wrapper {
width: 350px;
margin: 0 auto;
}
</style>
@code {
public void OnFileRemove(RemovingEventArgs args)
{
args.PostRawFile = false;
}
}