Search code examples
symfonysymfony-sonata

How to add other file extensions to SonataMediaBundle?


I need to upload other file types like (.ttf) but i can not.

Now, i'm editing the default source file configuration.php in DependencyInjection. I no it's the worst solution, but i don't know how doing that properly.

in their documentation, they don't suggest any config.

SonataMediaBundle documentation

Thanx


Solution

  • In your SonataMediaBundle configuration you have to add allowed_extensions and allowed_mime_types parameters.

    Configuration example for file provider:

    sonata_media:
        providers:
            file:
                allowed_extensions: ['ttf', 'pdf']
                allowed_mime_types: ['application/octet-stream', 'application/pdf']