0

So I have the file upload working well. However I need to set type of file that is allowed, where and how do I set the type of file that can be uploaded. It's supposed to be an image file, and I don't want users (obviously) uploading anything but an image. I would assume it's somewhere in validation.yml?

Thank you!

1 Answer 1

1

There are two ways, or using the file validation attribute, or the image validation attribute, this last as the accepted mime types as image/*

The examples on the site goes as followed:

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
    properties:
        bioFile:
            - File:
                maxSize: 1024k
                mimeTypes: [application/pdf, application/x-pdf]
                mimeTypesMessage: Please upload a valid PDF

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author
    properties:
        headshot:
            - Image:
                minWidth: 200
                maxWidth: 400
                minHeight: 200
                maxHeight: 400
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, Thank you, I couldn't find that for the life of me. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.