WhatIsHTML
WhatIsHTML

Reputation: 548

ng-file-upload with several patterns

I'm using ng-file-upload and I'm trying upload images or pdf files. I created simple form with file input, but it accept only pdf files. If I change order to 'image/*, .pdf' it accept only images but not pdf. How can I accept images and pdf files?

<input type="file" ngf-select ng-model="picFile" name="file" ngf-pattern="'.pdf, image/*'" accept="'.pdf, image/*'" ngf-accept="'.pdf, image/*'" ngf-max-size="2MB" required ngf-model-invalid="errorFile">

Example here http://jsfiddle.net/maqbzv15/3835/

Upvotes: 1

Views: 2748

Answers (2)

WhatIsHTML
WhatIsHTML

Reputation: 548

space after comma should be removed ngf-pattern="'.pdf, image/*'"

Upvotes: 2

M.Y.Mnu
M.Y.Mnu

Reputation: 718

Try below code for upload image and pdf file.

ng-accept="'.pdf,.jpg'|validate($file)"

and for multiple file you have to set ng-multiple to true

Upvotes: 1

Related Questions