How to restrict file name with special characters at the time of uploading file using TelerikUpload control

1 Answer 22 Views
Upload
Ankush
Top achievements
Rank 1
Ankush asked on 08 Jul 2021, 04:25 PM

I want to restrict file name with special characters at the time of uploading file in Dot Net blazer application using Telerik control. I am not finding any valid solution to validate file name, any specific solution for this.

I know we can write validation related code in each individual method but I want common solution for all files where I have used TelerikUpload control.

<TelerikUpload SaveUrl="@SaveUrl" RemoveUrl="@RemoveUrl"
                                   OnUpload="OnUploadEvent" OnRemove="@OnRemoveEvent"
                                   AllowedExtensions="@( new List<string>() { ".xlsx", ".xlsm", ".jpg", ".jpeg" ,".doc" ,".docx", ".pdf"} )"
                                   SaveField="files" RemoveField="fileToRemove">
</TelerikUpload>

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Jul 2021, 09:39 AM

Hi Ankush,

You can use the OnSelect event and cancel it if the file selection does not satisfy the criteria you have: https://docs.telerik.com/blazor-ui/components/upload/events#onselect.

If you want to make that part of form validation, see this sample project: https://github.com/telerik/blazor-ui/tree/master/upload/form-validation (note the readme file and how that is not yet available in the framework, so the validation logic must be implemented in the application code).

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Upload
Asked by
Ankush
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or