I am trying to filter the file dialogue window using p-fileUpload from primeng. I saw an example to to filter images as image/* and it works but i want ti filter for excel files. I tried file/excel, file/*.xls etc, but no help. Need help.
Try below inputs with accept property in p-fileUpload in Angular
Image filteraccept="image/*"
[accepts all image file types]
accept="image/*.jpeg"
[accepts only JPEG image file types]
File filteraccept="application/msexcel"
[accepts only xls file types]
accept=".xlsm,application/msexcel"
[accepts only xls & xlsm file types]
accept="application/msmsword"
[accepts only word file types]
我们可以像这样按所需类型过滤
accept=".xlsx,.pdf,.csv,.xls"
.html
<p-fileUpload accept="{{acceptedFiles}}" invalidFileTypeMessageDetail="Sólo se permiten ficheros {{acceptedFiles}}"></p-fileUpload>
.ts
acceptedFiles: string = ".pdf, .jpg, .png, .doc, .docx, .xls, .xlsx, .csv";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.