quma
quma

Reputation: 5733

ngf - file upload only allow images

I use ngf for file uploads and I havn't found a directive only to allow images to upload. Does anyone have any hint houw to do this?

<button type="submit" ngf-select="vm.uplo..." ngf-multiple="false" ngf-max-height="1000" ngf-max-size="5MB">Upload</button>

Upvotes: 2

Views: 2758

Answers (1)

Lucas
Lucas

Reputation: 10303

Use ngf-pattern. To allow: .jpg To Not allow: !.jpg. Remember always to validate server side as well.

   ngf-pattern="'.pdf,.jpg,video/*,!.jog'" // comma separated wildcard to filter file names and types allowed

To answer your comment @Juraj Kojdjak:

ngf-pattern allows you to put custom patterns and you could for example exclude a img ext type, ngf-accept is a straight forward way of accepting * images.

I have used file upload but not these directives

Upvotes: 6

Related Questions