October CMS resources and help articles

Simple and to the point. Optimized by the community.

Allow additional filetypes for uploads

8
by OFFLINE, last modified on January 24th, 2023

Image uploads

October uses a config array to check for allowed image extensions. This list is defined in \October\Rain\Filesystem\Definitions::imageExtensions().

To add your own extensions to the list you have to copy the default values to file_definitions.image_extensions in your config/cms.php file.

Note: If you use a upload widget in the file mode make sure to add your extension to the default_extensions key as described in the next section.

    // add in config/cms.php
    // ...
    'file_definitions' => [
        'image_extensions' => [
            // your new custom extensions
            'svg',
            // defaults
            'jpg',
            'jpeg',
            'bmp',
            'png',
            'webp',
            'gif',
        ]
    ]

General file uploads

October uses a config array to check for allowed upload extensions. This list is defined in \October\Rain\Filesystem\Definitions::defaultExtensions().

To add your own extensions to the list you have to copy the default values to file_definitions.default_extensions in your config/cms.php file.

If you use a upload widget in the image mode make sure to add your extension to the image_extensions key as described in the section above.

    // add in config/cms.php
    // ...
    'file_definitions' => [
        'default_extensions' => [
            // your new custom extensions
            'json',
            // defaults
            'jpg',
            'jpeg',
            'bmp',
            'png',
            'webp',
            'gif',
            'svg',
            'js',
            'map',
            'ico',
            'css',
            'less',
            'scss',
            'ics',
            'odt',
            'doc',
            'docx',
            'ppt',
            'pptx',
            'pdf',
            'swf',
            'txt',
            'xml',
            'ods',
            'xls',
            'xlsx',
            'eot',
            'woff',
            'woff2',
            'ttf',
            'flv',
            'wmv',
            'mp3',
            'ogg',
            'wav',
            'avi',
            'mov',
            'mp4',
            'mpeg',
            'webm',
            'mkv',
            'rar',
            'xml',
            'zip',
        ]
    ]

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?