Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[solved] Allowed File Extensions


Go to End


5 Posts   1956 Views

Avatar
patattrash

Community Member, 16 Posts

24 June 2014 at 3:02am

Just wondering if there is a better way to add to the $allowed_extension list in File.php. It seems you used to be able to add this to your _config file, but because it's been switched to private I'm not able to do that anymore. Wondering if there is a way to add file types without editing the framework's core.

Avatar
(deleted)

Community Member, 473 Posts

24 June 2014 at 9:52am

You now use the Config API or a YAML file to do this.

The YAML syntax is:

File:
  allowed_extensions:
    - new_ext
    - other_ext

That would go in mysite/_config/config.yml.

Avatar
camfindlay

Forum Moderator, 267 Posts

24 June 2014 at 10:28am

Thanks for that simon_w, perhaps we should add this example to the docs? Best place would probably be http://doc.silverstripe.org/framework/en/reference/uploadfield

patattrash, if this solves your problem please edit your original thread title to include [solved] prefix :)

Avatar
patattrash

Community Member, 16 Posts

25 June 2014 at 8:55am

simon_w, thanks for the quick reply and sorry I didn't notice the update earlier. That took care of it for me.

Avatar
camfindlay

Forum Moderator, 267 Posts

25 June 2014 at 2:56pm

I have actually created a pull request to add this to the documentation https://github.com/silverstripe/silverstripe-framework/pull/3233