You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _contentTemplates/upload/notes.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
#server-security-note
2
2
3
-
>warning File upload and remove controllers can create application vulnerabilities. Learn about all possible security risks and how to avoid them. Do not trust any part of the upload or remove request and implement server-side validation.
3
+
>warning File handling, saving and deletion can create application vulnerabilities. This includes any related controller methods. Learn about all possible security risks and how to avoid them. Do not trust the user files or requests, and implement server-side validation.
Copy file name to clipboardExpand all lines: components/fileselect/events.md
+33-20Lines changed: 33 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,21 +39,25 @@ Property | Type | Description
39
39
40
40
## OnSelect
41
41
42
-
The `OnSelect` fires when one or more files have been selected. The selection of files is achieved either through the **Select Files** button or by dropping the files anywhere in the component.
42
+
The `OnSelect`event fires each time when the user selects file(s) through the **Select Files** button or by drag and drop anywhere in the component.
43
43
44
-
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo). If you set its `IsCancelled` property to `true`, the component will ignore the user action and the selected files will not appear in the component file list.
44
+
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo). If you set its `IsCancelled` property to `true`, the component ignores the user action and all newly selected files do not appear in the component file list.
45
+
46
+
`OnSelect` fires for both valid and invalid files. You can verify if the file is valid by checking the validation-related properties of each [`FileSelectFileInfo`](slug:fileselect-events#fileselectfileinfo) object. If necessary, the application can still handle invalid files, for example, read their content.
45
47
46
48
See the [example below](#example).
47
49
48
50
## OnRemove
49
51
50
-
The `OnRemove` fires when a file has been removed from the list of selected files either by clicking the **x** icon or by pressing the `Del` key.
52
+
The `OnRemove` event fires when the user deletes a file from the list by clicking the **x** icon or by pressing the `Del` key.
53
+
54
+
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo). The `Files` collection in the event argument always contains a single `FileSelectFileInfo` object. This is unlike the `OnSelect` event where `Files` can include one or more files.
51
55
52
-
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo). The `Files` collection in the event argument always contains a single `FileSelectFileInfo` object. This is unlike the `OnSelect` event where `Files` may include one or more files.
56
+
`OnRemove` fires for both valid and invalid files.
53
57
54
58
## Example
55
59
56
-
>caption Handling the `OnSelect` and `OnRemove` events of the FileSelect
60
+
>caption Handle the FileSelect `OnSelect` and `OnRemove` events
57
61
58
62
````RAZOR
59
63
@using System.Threading
@@ -66,35 +70,44 @@ The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo)
Copy file name to clipboardExpand all lines: components/fileselect/validation.md
+48-23Lines changed: 48 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,43 +8,68 @@ published: true
8
8
position: 10
9
9
---
10
10
11
-
# FileSelect - Selected Files Validation
11
+
# FileSelect File Validation
12
12
13
13
If you want to validate the selected files, you should implement the validation in two parts:
14
14
15
-
*client validation - performed by the Telerik FileSelect component
16
-
*server validation - must be implemented in the application endpoints
15
+
*Client validation—performed by the Telerik FileSelect component
16
+
*Server validation—must be implemented in the application backend or endpoints
17
17
18
-
The Telerik FileSelect component offers parameters to validate the file selection on the client:
18
+
## Parameters
19
19
20
-
*`Accept` - `string` - not validation per se, but this parameter can [instruct the browser what file types to allow users to select](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept).
21
-
*`AllowedExtensions` - `List<string>` - a list of valid file extensions. Choosing other file types will mark them as invalid in the UI. The default value is `null`, which allows all extensions.
22
-
*`MinFileSize`- `int?` - the minimum size of a file in bytes. Files with a smaller size will be marked as invalid in the UI.
23
-
*`MaxFileSize`- `int?` - the maximum size of a file in bytes. Files with a larger size will be marked as invalid in the UI.
20
+
The Telerik [FileSelect component offers parameters](slug:Telerik.Blazor.Components.TelerikFileSelect) to validate the file selection on the client:
24
21
25
-
>caption Client validation in the Telerik FileSelect component
22
+
*`AllowedExtensions`
23
+
*`MinFileSize`
24
+
*`MaxFileSize`
26
25
27
-
For brevity, this sample does not showcase actual upload of the files. You can find an example in the [FileSelect Events article](slug:fileselect-events).
26
+
Selected files that don't meet the defined criteria are marked as invalid in the component UI.
27
+
28
+
The FileSelect also provides an `Accept` parameter. It does not enforce validation, but [instructs the browser what file types to allow users to select](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept). This can also help users find the correct files more easily.
29
+
30
+
## Events
31
+
32
+
The [FileSelect fires its `OnSelect` and `OnRemove` events](slug:fileselect-events) for both valid and invalid files. The application can confirm file validity through the [event argument properties](slug:fileselect-events#fileselectfileinfo) and decide how to proceed.
33
+
34
+
## Example
35
+
36
+
For brevity, the code below does not handle the selected file. See a full example in the [FileSelect Events article](slug:fileselect-events#example).
37
+
38
+
>caption Telerik FileSelect file validation
28
39
29
40
````RAZOR
30
-
@* Some images are only allowed, min size 1KB, max size 4MB *@
0 commit comments