Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit document file upload type #286

Open
joemonaco opened this issue Jul 24, 2019 · 2 comments
Open

Limit document file upload type #286

joemonaco opened this issue Jul 24, 2019 · 2 comments

Comments

@joemonaco
Copy link

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

@DorienD
Copy link

DorienD commented Feb 28, 2020

I would also like this :)

@rossriley
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants