# FileSelect File Validation

If you want to validate the selected files, you should implement the validation in two parts:

* Client validation—performed by the Telerik FileSelect component
* Server validation—must be implemented in the application backend or endpoints

## Parameters

The Telerik [FileSelect component offers parameters](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikfileselect) to validate the file selection on the client:

* `AllowedExtensions`
* `MinFileSize`
* `MaxFileSize`

Selected files that don't meet the defined criteria are marked as invalid in the component UI.

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.

## Events

The [FileSelect fires its `OnSelect` and `OnRemove` events](https://www.telerik.com/blazor-ui/documentation/components/fileselect/events) for both valid and invalid files. The application can confirm file validity through the [event argument properties](https://www.telerik.com/blazor-ui/documentation/components/fileselect/events#fileselectfileinfo) and decide how to proceed.

## Example

For brevity, the code below does not handle the selected file. See a full example in the [FileSelect Events article](https://www.telerik.com/blazor-ui/documentation/components/fileselect/events#example).

> caption Telerik FileSelect file validation

<demo metaUrl="client/fileselect/validation/" height="250"></demo>

> 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.
>
> * [ASP.NET Core Secuirty Considerations](https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads)
> * [File Upload Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html)
> * [Upload Path Traversal](https://security.stackexchange.com/questions/177307/path-traversal-via-filename)
>
> The code examples in this documentation do not implement security measures for simplicity and brevity.

## See Also

* [Live Demo: FileSelect Validation](https://demos.telerik.com/blazor-ui/fileselect/validation)
* [FileSelect Overview](https://www.telerik.com/blazor-ui/documentation/components/fileselect/overview)
* [FileSelect Events](https://www.telerik.com/blazor-ui/documentation/components/fileselect/events)
