FileSelect with custom template and restrictions

1 Answer 17 Views
FileSelect
Murray
Top achievements
Rank 1
Iron
Veteran
Murray asked on 14 Jun 2021, 02:16 PM

How can I show the File Too Large error message in my own custom kendoFileSelectFileTemplate?

What do I need to do?

1 Answer, 1 is accepted

Sort by
0
Yanmario
Telerik team
answered on 16 Jun 2021, 10:55 AM

Hi Murray,

Using the kendoFileSelectFileTemplate provides you access to the uploaded files and their size. 

<ng-template kendoFileSelectFileTemplate let-files let-state="state">

This allows implementing a separate HTML element that can check the file size(in bytes) and, depending on the statement, display an error message using the *ngIf structural directive.

 <div class="fileError" *ngIf="files[0].size > 150000">
          (File is too large. File size above 150kb)
</div>

StackBlitz example implementation:

https://stackblitz.com/edit/fileselect-template-display-error-depending-on-file-size?file=app/app.component.ts

I hope this helps.

Regards,
Yanmario Menev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
FileSelect
Asked by
Murray
Top achievements
Rank 1
Iron
Veteran
Answers by
Yanmario
Telerik team
Share this question
or