boltforms icon indicating copy to clipboard operation
boltforms copied to clipboard

Limit document file upload type

Open joemonaco opened this issue 6 years ago • 2 comments

I am trying to specify only .doc, .docx, and .pdf as file uploads and cant seem to find anything on how specify those constraints

joemonaco avatar Jul 24 '19 19:07 joemonaco

I would also like this :)

DorienD avatar Feb 28 '20 09:02 DorienD

Since BoltForms will load in any of the default Symfony validator constraints you should be able to do this something like:

fields:
    upload:
        type: file
            options:
                required: true
                label: Your Upload
                constraints: 
                    - File:
                        mimeTypes: ["application/pdf", "image/jpg", "image.png"]

All of the options outlined in the symfony docs: https://symfony.com/doc/current/reference/constraints/File.html#mimetypes

Should apply since the options you configure are passed straight to the validator.

rossriley avatar Mar 09 '20 06:03 rossriley