十月CMS不允许的文件类型 [英] October CMS disallowed file types

查看:109
本文介绍了十月CMS不允许的文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在十月CMS中将.pptx文件上载到媒体库,但由于不允许使用文件类型而出现错误.我已经尝试过使用Stackoverflow的以下建议:

I'm trying to upload a .pptx file to the media library in October CMS and I'm getting an error because the filetype is not allowed. I have tried using the following suggestion from Stackoverflow:

'fileDefinitions' => [ 'assetExtensions' => array_merge(FileDefinitions::get('assetExtensions'), ['docx']), ],

'fileDefinitions' => [ 'assetExtensions' => array_merge(FileDefinitions::get('assetExtensions'), ['docx']), ],

但是我收到有关FileDefinitions类不存在的错误消息.我还尝试了另一种建议,将其添加到/config/cms.php中的fileTypes数组,但这也不起作用,因为这种包含文件的方式似乎已经消失了.

But I get an error message about FileDefinitions class not existing. I have also tried another suggestion of adding to a fileTypes array in /config/cms.php but that doesn't work either as this way of including files seems to be gone.

十月份的CMS git repo有一个请求请求,该请求向源代码中添加了文件类型,但是我觉得这不是一个好主意,因为不同的用户有不同的需求,并且每次有人需要新的系统时都必须更新系统文件类型已添加!无论如何,有人知道简单地在允许文件类型数组中添加新文件类型的好方法吗?

The October CMS git repo had a pull request which added a file type to the source code but I feel this is not a great idea as different users have different needs and the system would have to be updated every time someone wants a new file type added! Anyway, does anyone know a good way that works of simply adding a new file type the the allow file types array?

似乎它应该是一个简单的配置设置,但对我而言,我找不到任何有效的参考.

Seems like it should be a simple config setting but for the life of me I can't find any working reference.

推荐答案

我想您在其中添加了错误扩展名的 pptx 而不是 ppxt @David Lundquist

I guess you added wrong extension there its pptx not ppxt @David Lundquist

<?php

return [

    'fileDefinitions' => [
        'defaultExtensions' => [
            'pptx'
         ]
    ],

    // other config
    ....
];

只需将此行添加到config/cms.php配置中,它就可以正常工作.

just add this lines to the config/cms.php config and it should work.

但现在请确保,如果要允许更多扩展名,则需要仅在此处手动添加文件.

.

but now make sure that it will now only allow files .pptx if you want to allow more extensions you need to add them here manually.

'jpg','jpeg','bmp','png','webp','gif','svg','js','map','ico','css','less' ,"scss","ics","odt","doc","docx","pdf","swf","txt","xml","ods","xls","xlsx","eot","woff","woff2","ttf","flv","wmv","mp3","ogg","wav","avi","mov","mp4","mpeg" ,"webm","mkv","rar","zip"

'jpg', 'jpeg', 'bmp', 'png', 'webp', 'gif', 'svg', 'js', 'map', 'ico', 'css', 'less', 'scss', 'ics', 'odt', 'doc', 'docx', 'pdf', 'swf', 'txt', 'xml', 'ods', 'xls', 'xlsx', 'eot', 'woff', 'woff2', 'ttf', 'flv', 'wmv', 'mp3', 'ogg', 'wav', 'avi', 'mov', 'mp4', 'mpeg', 'webm', 'mkv', 'rar', 'zip'

这是默认列表,因此只需复制此列表并在此处添加您自己的额外扩展名即可.

this is the default list so just copy this list and add your own extra extension here..

如果您使用的是 pptx ..它将起作用.

in you case its pptx .. and it will work.

我已经检查了代码库,没有其他简单的方法可以扩展此代码. {可能很困难,需要额外的插件和挂钩等..}

I have checked code base there is no other easy way to extend this. { probably hard way require extra plugins and hooks etc ..}

请勿尝试该array_merge解决方案,因为FileDefinitions代码将被递归调用以再次获取cms配置,它将再次执行array_merge ... (不在本主题范围内,但它无法正常工作,因此请勿尝试这样做)

最好使用这一功能,并且不会影响更新.

so better to use this one and this will not affect on updates.

每当有人要添加新文件类型时更新!

updated every time someone wants a new file type added!

不要为此担心,他们提供了配置文件:)

don't worry for only this purpose they provided config files :)

尝试一下,如果它不起作用,请发表评论.

try it, if its not working please comment.

这篇关于十月CMS不允许的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆