angular primeng file upload restrict multiple mime types

primeNG version: 6.1.4

PrimeNG file upload docs don’t specify how to restrict the file types allowed for multiple or different mime types (except for images)

Name Type Default Description
accept string false Pattern to restrict the allowed file types such as “image/*”.

I’ve found 2 answers which suggests to add file types separated by ‘commas’ without spaces between them like so

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

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]

but it didn’t work with mime types. In the end I had to specify different file types using only its extension (without spaces between commas)

accept=”.pdf,.doc,.docx,.xls,.xlsx”

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s