Back to Devexpress

DxUpload.ValidateByAcceptedFileTypes Property

blazor-devexpress-dot-blazor-dot-dxupload-e443a3fa.md

latest2.9 KB
Original Source

DxUpload.ValidateByAcceptedFileTypes Property

Specifies whether the component validates files against accepted file types before uploading them.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(true)]
[Parameter]
public bool ValidateByAcceptedFileTypes { get; set; }

Property Value

TypeDefaultDescription
Booleantrue

true to validate files against accepted file types; otherwise, false.

|

Remarks

You can use the following APIs to specify file types and extensions accepted by Upload.

Open File Dialog Filter

The AcceptedFileTypes property sets the file type filter in the Open File dialog. The property value is passed to the accept attribute of the underlying input HTML element.

If a user removes the filter, the Open File dialog displays all file types and users can select files that do not match AcceptedFileTypes.

A user can also skip the Open File dialog and simply drop files onto the drop zone.

File Type Validation

Once a file is added to the file list, the component validates the following:

If validation fails, the Upload cannot upload the file and displays an error message.

Examples

The following example disables MIME type validation (ValidateByAcceptedFileTypes is false). In this case, the AcceptedFileTypes property only specifies a filter for the Open File dialog.

razor
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/Upload/"
          AcceptedFileTypes="@(new List<string> { "image/*"})"
          ValidateByAcceptedFileTypes="false">
</DxUpload>

See Also

DxUpload Class

DxUpload Members

DevExpress.Blazor Namespace