OTF字体未在Wordpress中上传

时间:2017-06-21 11:52:32

标签: wordpress fonts wordpress-theming mime-types

我想在WordPress信息中心上传自定义字体。当我尝试上传字体文件时,它显示错误:

Sorry, this file type is not permitted for security reasons.

然后我通过使用以下代码允许字体所有文件:

  add_filter('upload_mimes', 'add_custom_upload_mimes');
  function add_custom_upload_mimes($existing_mimes) {
    $existing_mimes['otf'] = 'application/x-font-opentype';
    $existing_mimes['woff'] = 'application/x-font-woff';
    $existing_mimes['ttf'] = 'application/x-font-ttf';
    $existing_mimes['svg'] = 'image/svg+xml';
    $existing_mimes['eot'] = 'application/vnd.ms-fontobject';
    return $existing_mimes;
  }

现在所有类型的字体都上传了,但是当我上传.otf字体时,它显示的是同样的错误。

请帮我解决此问题。在此先感谢。

3 个答案:

答案 0 :(得分:2)

尝试使用

$existing_mimes['otf'] = 'font/otf';

$existing_mimes['otf'] = 'application/font-sfnt';

答案 1 :(得分:1)

您发表这篇文章已有很长时间了。但是我正在使用一个名为“ WP Add Mime Types”的插件。

作为插件设置(设置-> Myme类型设置)中的值,我添加了以下内容: otf = application / x-font-opentype

对我有用:)

答案 2 :(得分:0)

打击是解决此问题的步骤。

打开WordPress安装的wp-config.php文件,并在显示/ *的行上方打开,停止编辑!快乐的博客。 * /在任何地方添加以下代码:

define('ALLOW_UNFILTERED_UPLOADS', true);

参考:https://tribulant.com/blog/wordpress/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/

相关问题