3 Answers, 1 is accepted
0
Hello John,
Preventing the user to select a specific type of file from his machine is not allowed by the browsers. We could apply the accept attribute
https://www.telerik.com/kendo-angular-ui/components/upload/api/UploadComponent/#toc-accept
to the <input type="file" /> element. However this only sets the default file type to be displayed in the file select window and again does not prevent the user from selecting any type of file.
In order to validate if the expected file type is selected, the following approach could be used:
https://www.telerik.com/kendo-angular-ui/components/upload/restrictions/#toc-types-of-file-restrictions
Regards,
Dimiter Madjarov
Progress Telerik
Preventing the user to select a specific type of file from his machine is not allowed by the browsers. We could apply the accept attribute
https://www.telerik.com/kendo-angular-ui/components/upload/api/UploadComponent/#toc-accept
to the <input type="file" /> element. However this only sets the default file type to be displayed in the file select window and again does not prevent the user from selecting any type of file.
In order to validate if the expected file type is selected, the following approach could be used:
https://www.telerik.com/kendo-angular-ui/components/upload/restrictions/#toc-types-of-file-restrictions
Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
n/a
Top achievements
Rank 1
answered on 28 Jun 2019, 01:14 PM
Is there an example of this working for excel?
I have tried
<
kendo-upload
[saveUrl]="uploadSaveUrl"
[removeUrl]="uploadRemoveUrl"
(upload)="uploadEventHandler($event)"
(remove)="removeEventHandler($event)"
[restrictions]="myRestrictions"
[accept]="acceptString">
</
kendo-upload
>
With
export class UploadComponent implements OnInit {
@Input() application: Application;
uploadSaveUrl = environment.serviceUrl + "api/UploadFiles/UploadFile"; // should represent an actual API endpoint
uploadRemoveUrl = 'removeUrl'; // should represent an actual API
userDataSubscription: Subscription;
userData;
acceptString: ".xls,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel";
0
Accepted
Hi John,
Here is an example of setting file restrictions and an accept attribute to the Upload component.
https://stackblitz.com/edit/angular-qff6mq?file=app%2Fupload.component.ts
Regards,
Dimiter Madjarov
Progress Telerik
Here is an example of setting file restrictions and an accept attribute to the Upload component.
https://stackblitz.com/edit/angular-qff6mq?file=app%2Fupload.component.ts
Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.