Skip to content
Advertisement

How to filter the file types in primeng p-fileupload component

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.

Advertisement

Answer

Try below inputs with accept property in p-fileUpload in Angular

  1. Image filter
    accept="image/*"[accepts all image file types]
    accept="image/*.jpeg"[accepts only JPEG image file types]

  2. File filter
    accept="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]

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement